Make API return error before raising error again (#606)

This change makes it so any API clients can show the same error as what
happens in the terminal where you run the API. Useful for various WebUIs
to display more helpful error messages to users.

Co-authored-by: CapableWeb <capableweb@domain.com>
This commit is contained in:
CapableWeb
2022-09-16 13:33:42 +02:00
committed by GitHub
parent f9b272a7b9
commit 58baf9533b

View File

@ -247,6 +247,15 @@ class DreamServer(BaseHTTPRequestHandler):
except CanceledException:
print(f"Canceled.")
return
except Exception as e:
print("Error happened")
print(e)
self.wfile.write(bytes(json.dumps(
{'event': 'error',
'message': str(e),
'type': e.__class__.__name__}
) + '\n',"utf-8"))
raise e
class ThreadingDreamServer(ThreadingHTTPServer):