diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-05-31 16:16:14 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-31 16:16:14 +0000 |
commit | d9bd7ada7675d3903181a6a65ba625d82cf88443 (patch) | |
tree | 30470f64d84cadc4140023c0bf34c35bb68f79b0 /modules/errors.py | |
parent | 78a602ae8c006077ca93913576335a3a33dba7cb (diff) | |
parent | 52b8752e6201e24c783f674f8dc0681027e10ea9 (diff) | |
download | stable-diffusion-webui-gfx803-d9bd7ada7675d3903181a6a65ba625d82cf88443.tar.gz stable-diffusion-webui-gfx803-d9bd7ada7675d3903181a6a65ba625d82cf88443.tar.bz2 stable-diffusion-webui-gfx803-d9bd7ada7675d3903181a6a65ba625d82cf88443.zip |
Merge pull request #10820 from akx/report-error
Add & use modules.errors.print_error
Diffstat (limited to 'modules/errors.py')
-rw-r--r-- | modules/errors.py | 16 |
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])
|