summaryrefslogtreecommitdiff
path: root/lib/exceptions.py
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2023-09-07 13:25:47 -0400
committerGitHub <noreply@github.com>2023-09-07 19:25:47 +0200
commitaf96d720e9340e02b1ec6dafe10bf9a47e045804 (patch)
treea49d9b1570050db02ff8f17b754e54ec7b9a6e1a /lib/exceptions.py
parent3db335b0f41ebfcc694914bba5bf81aed9ae98d4 (diff)
improve params errors (#2437)
Diffstat (limited to 'lib/exceptions.py')
-rw-r--r--lib/exceptions.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/exceptions.py b/lib/exceptions.py
index a9820ac3..3a6b456c 100644
--- a/lib/exceptions.py
+++ b/lib/exceptions.py
@@ -2,6 +2,36 @@
#
# Copyright (c) 2010 Authors
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
+import traceback
+
class InkstitchException(Exception):
pass
+
+
+def format_uncaught_exception():
+ """Format the current exception as a request for a bug report.
+
+ Call this inside an except block so that there is an exception that we can
+ call traceback.format_exc() on.
+ """
+
+ # importing locally to avoid any possibility of circular import
+ from lib.utils import version
+ from .i18n import _
+
+ message = ""
+ message += _("Ink/Stitch experienced an unexpected error. This means it is a bug in Ink/Stitch.")
+ message += "\n\n"
+ # L10N this message is followed by a URL: https://github.com/inkstitch/inkstitch/issues/new
+ message += _("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")
+ message += " https://github.com/inkstitch/inkstitch/issues/new\n\n"
+ message += _("Include the error description and also (if possible) the svg file.")
+ message += '\n\n\n'
+ message += version.get_inkstitch_version() + '\n'
+ message += traceback.format_exc()
+
+ return message