From cef01b2981429a4e63c69f99219e80d860c17a3d Mon Sep 17 00:00:00 2001 From: John Parejko Date: Tue, 11 Jan 2022 15:27:04 -0800 Subject: [PATCH] Include original error from Stats Getting some more information out of the Stats module might help debug problems when loading stats data. --- snakeviz/cli.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/snakeviz/cli.py b/snakeviz/cli.py index b33a9b8..fe00347 100644 --- a/snakeviz/cli.py +++ b/snakeviz/cli.py @@ -92,12 +92,13 @@ def main(argv=None): try: Stats(filename) - except Exception: - parser.error(('The file %s is not a valid profile. ' % filename) + + except Exception as e: + parser.error(f'The file {filename} is not a valid profile. ' 'Generate profiles using: \n\n' '\tpython -m cProfile -o my_program.prof my_program.py\n\n' 'Note that snakeviz must be run under the same ' - 'version of Python as was used to create the profile.\n') + 'version of Python as was used to create the profile.\n' + f'Original exception from Stats module:\n{type(e).__name__}: {e}\n') filename = quote(filename, safe='')