Error-handling and --debug option to print stack-trace for all magic-folder commands

This commit is contained in:
meejah 2016-05-23 14:56:06 -06:00 committed by Brian Warner
parent 4509c7dafd
commit 041aabd8c4

View File

@ -394,6 +394,9 @@ class MagicFolderCommand(BaseOptions):
["leave", None, LeaveOptions, "Leave a Magic Folder."],
["status", None, StatusOptions, "Display stutus of uploads/downloads."],
]
optFlags = [
["debug", "d", "Print full stack-traces"],
]
def postOptions(self):
if not hasattr(self, 'subOptions'):
raise usage.UsageError("must specify a subcommand")
@ -420,7 +423,12 @@ def do_magic_folder(options):
so.stdout = options.stdout
so.stderr = options.stderr
f = subDispatch[options.subCommand]
return f(so)
try:
return f(so)
except Exception as e:
print("Error: %s" % (e,))
if options['debug']:
raise
subCommands = [
["magic-folder", None, MagicFolderCommand,