diff options
| author | Lex Neva <lexelby@users.noreply.github.com> | 2023-09-07 13:25:47 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-07 19:25:47 +0200 |
| commit | af96d720e9340e02b1ec6dafe10bf9a47e045804 (patch) | |
| tree | a49d9b1570050db02ff8f17b754e54ec7b9a6e1a /inkstitch.py | |
| parent | 3db335b0f41ebfcc694914bba5bf81aed9ae98d4 (diff) | |
improve params errors (#2437)
Diffstat (limited to 'inkstitch.py')
| -rw-r--r-- | inkstitch.py | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/inkstitch.py b/inkstitch.py index 1dc5a3e3..91a0f18a 100644 --- a/inkstitch.py +++ b/inkstitch.py @@ -7,10 +7,11 @@ import pstats import logging import os import sys -import traceback from argparse import ArgumentParser from io import StringIO +from lib.exceptions import InkstitchException, format_uncaught_exception + if getattr(sys, 'frozen', None) is None: # When running in development mode, we want to use the inkex installed by # pip install, not the one bundled with Inkscape which is not new enough. @@ -28,7 +29,7 @@ from lxml.etree import XMLSyntaxError import lib.debug as debug from lib import extensions from lib.i18n import _ -from lib.utils import restore_stderr, save_stderr, version +from lib.utils import restore_stderr, save_stderr # ignore warnings in releases if getattr(sys, 'frozen', None): @@ -90,24 +91,15 @@ else: msg += "\n\n" msg += _("Try to import the file into Inkscape through 'File > Import...' (Ctrl+I)") errormsg(msg) + except InkstitchException as exc: + errormsg(str(exc)) except Exception: - exception = traceback.format_exc() + errormsg(format_uncaught_exception()) + sys.exit(1) finally: restore_stderr() if shapely_errors.tell(): errormsg(shapely_errors.getvalue()) - if exception: - errormsg(_("Ink/Stitch experienced an unexpected error. This means it is a bug in Ink/Stitch.") + "\n") - errormsg(_("If you'd like to help please\n" - "- copy the entire error message below\n" - "- save your SVG file and\n" - "- create a new issue at https://github.com/inkstitch/inkstitch/issues") + "\n") - errormsg(_("Include the error description and also (if possible) " - "the svg file.") + "\n") - errormsg(version.get_inkstitch_version() + "\n") - errormsg(exception) - sys.exit(1) - else: - sys.exit(0) + sys.exit(0) |
