aboutsummaryrefslogtreecommitdiff
path: root/modules/errors.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-05-31 19:31:19 +0300
committerGitHub <noreply@github.com>2023-05-31 19:31:19 +0300
commit177d4b6828eee6a9aa1e9f2cf4877ad9ae8fcae4 (patch)
tree466c92812f7b978cf3a535187c18be78c4e26d37 /modules/errors.py
parentc1a5068ebea127412dfaaa6598795196a64200f1 (diff)
parent881de0df38c1fa6d0d61f7bc6fc93c100a9f35d0 (diff)
Merge branch 'dev' into sync-req
Diffstat (limited to 'modules/errors.py')
-rw-r--r--modules/errors.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/errors.py b/modules/errors.py
index da4694f8..41d8dc93 100644
--- a/modules/errors.py
+++ b/modules/errors.py
@@ -1,7 +1,23 @@
import sys
+import textwrap
import traceback
+def print_error(
+ message: str,
+ *,
+ exc_info: bool = False,
+) -> None:
+ """
+ Print an error message to stderr, with optional traceback.
+ """
+ for line in message.splitlines():
+ print("***", line, file=sys.stderr)
+ if exc_info:
+ print(textwrap.indent(traceback.format_exc(), " "), file=sys.stderr)
+ print("---")
+
+
def print_error_explanation(message):
lines = message.strip().split("\n")
max_len = max([len(x) for x in lines])