| 48 | |
| 49 | |
| 50 | def displayErrorMessage(err, error_log_path): |
| 51 | import ctypes |
| 52 | import urllib.parse |
| 53 | import subprocess |
| 54 | |
| 55 | MB_YESNOCANCEL = 0x3 |
| 56 | MB_ICONEXCLAIMATION = 0x30 |
| 57 | |
| 58 | ID_YES = 0x6 |
| 59 | ID_NO = 0x7 |
| 60 | ID_CANCEL = 0x2 |
| 61 | |
| 62 | err_message = "%s: %s" % (type(err).__name__, err) |
| 63 | err_title = "Unhandled exception: %s\nReport error?" % err_message |
| 64 | |
| 65 | res = ctypes.windll.user32.MessageBoxW(0, err_title, "ZeroNet error", MB_YESNOCANCEL | MB_ICONEXCLAIMATION) |
| 66 | if res == ID_YES: |
| 67 | import webbrowser |
| 68 | report_url = "https://github.com/HelloZeroNet/ZeroNet/issues/new?assignees=&labels=&template=bug-report.md&title=%s" |
| 69 | webbrowser.open(report_url % urllib.parse.quote("Unhandled exception: %s" % err_message)) |
| 70 | if res in [ID_YES, ID_NO]: |
| 71 | subprocess.Popen(['notepad.exe', error_log_path]) |
| 72 | |
| 73 | def prepareShutdown(): |
| 74 | import atexit |