From 6581812d19756fe3dedccf161706fe22ba65f8c4 Mon Sep 17 00:00:00 2001 From: chrysn Date: Sun, 6 Nov 2016 14:33:17 +0100 Subject: [PATCH 1/2] image: add check to give more meaningful error message --- morituri/image/image.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/morituri/image/image.py b/morituri/image/image.py index 97a3dc05..1c7cb2d6 100644 --- a/morituri/image/image.py +++ b/morituri/image/image.py @@ -250,6 +250,9 @@ def stop(self): self.setException(taskk.exception) break + if taskk.length is None: + raise ValueError("Track length was not found; look for " + "earlier errors in debug log (set RIP_DEBUG=4)") # print '%d has length %d' % (trackIndex, taskk.length) index = track.indexes[1] assert taskk.length % common.SAMPLES_PER_FRAME == 0 From f9af58ed3e6a5a3df43a54349d167b737a7be0d4 Mon Sep 17 00:00:00 2001 From: chrysn Date: Sun, 6 Nov 2016 14:35:07 +0100 Subject: [PATCH 2/2] main: show TaskException instead of raising them a TaskException already wraps another exception; raising it gives a hard-to-read multi-line message instead of showing the clean wrapped original backtrace; for comparison, an asserton error in image.py line 253: exception AssertionError at /home/chrysn/git/whipper/morituri/image/image.py:253: stop(): Track length was not found; look for earlier errors in debug log (set RIP_DEBUG=4) Traceback (most recent call last): File "/home/chrysn/git/whipper/morituri/extern/task/task.py", line 497, in _startWrap task.start(self) File "/home/chrysn/git/whipper/morituri/extern/task/task.py", line 395, in start BaseMultiTask.start(self, runner) File "/home/chrysn/git/whipper/morituri/extern/task/task.py", line 330, in start self.next() File "/home/chrysn/git/whipper/morituri/extern/task/task.py", line 401, in next BaseMultiTask.next(self) File "/home/chrysn/git/whipper/morituri/extern/task/task.py", line 351, in next self.stop() File "/home/chrysn/git/whipper/morituri/image/image.py", line 253, in stop assert taskk.length is not None, "Track length was not found; look for earlier errors in debug log (set RIP_DEBUG=4)" AssertionError: Track length was not found; look for earlier errors in debug log (set RIP_DEBUG=4) vs. Traceback (most recent call last): File "", line 1, in File "/home/chrysn/git/whipper/morituri/rip/main.py", line 27, in main ret = c.parse(sys.argv[1:]) File "/home/chrysn/git/whipper/morituri/rip/main.py", line 94, in parse logcommand.LogCommand.parse(self, argv) File "/home/chrysn/git/whipper/morituri/common/logcommand.py", line 62, in parse command.Command.parse(self, argv) File "/home/chrysn/git/whipper/morituri/extern/command/command.py", line 401, in parse return self.subCommands[command].parse(args[1:]) File "/home/chrysn/git/whipper/morituri/common/logcommand.py", line 62, in parse command.Command.parse(self, argv) File "/home/chrysn/git/whipper/morituri/extern/command/command.py", line 401, in parse return self.subCommands[command].parse(args[1:]) File "/home/chrysn/git/whipper/morituri/common/logcommand.py", line 62, in parse command.Command.parse(self, argv) File "/home/chrysn/git/whipper/morituri/extern/command/command.py", line 363, in parse ret = self.do(args) File "/home/chrysn/git/whipper/morituri/rip/image.py", line 184, in do cueImage.setup(runner) File "/home/chrysn/git/whipper/morituri/image/image.py", line 75, in setup runner.run(verify) File "/home/chrysn/git/whipper/morituri/extern/task/task.py", line 490, in run raise TaskException(task.exception, message=msg) morituri.extern.task.task.TaskException: (AssertionError('Track length was not found; look for earlier errors in debug log (set RIP_DEBUG=4)',), 'exception AssertionError at /home/chrysn/git/whipper/morituri/image/image.py:253: stop(): Track length was not found; look for earlier errors in debug log (set RIP_DEBUG=4)\nTraceback (most recent call last):\n File "/home/chrysn/git/whipper/morituri/extern/task/task.py", line 497, in _startWrap\n task.start(self)\n File "/home/chrysn/git/whipper/morituri/extern/task/task.py", line 395, in start\n BaseMultiTask.start(self, runner)\n File "/home/chrysn/git/whipper/morituri/extern/task/task.py", line 330, in start\n self.next()\n File "/home/chrysn/git/whipper/morituri/extern/task/task.py", line 401, in next\n BaseMultiTask.next(self)\n File "/home/chrysn/git/whipper/morituri/extern/task/task.py", line 351, in next\n self.stop()\n File "/home/chrysn/git/whipper/morituri/image/image.py", line 253, in stop\n assert taskk.length is not None, "Track length was not found; look for earlier errors in debug log (set RIP_DEBUG=4)"\nAssertionError: Track length was not found; look for earlier errors in debug log (set RIP_DEBUG=4)\n') --- morituri/rip/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/morituri/rip/main.py b/morituri/rip/main.py index b6f82be3..93ad0001 100644 --- a/morituri/rip/main.py +++ b/morituri/rip/main.py @@ -45,7 +45,10 @@ def main(): 'rip: error: Could not create encoded file.\n') return 255 - raise + # in python3 we can instead do `raise e.exception` as that would show + # the exception's original context + sys.stderr.write(e.exceptionMessage) + return 255 except command.CommandError, e: sys.stderr.write('rip: error: %s\n' % e.output) return e.status