MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / on_task_exception

Method on_task_exception

pywebio/session/base.py:132–151  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

130 return self._closed
131
132 def on_task_exception(self):
133 from ..output import toast, popup, put_error, PopupSize
134 from . import run_js
135 from . import info as session_info
136
137 # log exception in server
138 logger.exception('Unhandled error in pywebio app')
139
140 try:
141 toast_msg = "应用发生内部错误" if 'zh' in session_info.user_language else "An internal error occurred in the application"
142 if type(self).debug:
143 e_type, e_value, e_tb = sys.exc_info()
144 lines = traceback.format_exception(e_type, e_value, e_tb)
145 traceback_msg = ''.join(lines)
146 popup(title=toast_msg, content=put_error(traceback_msg), size=PopupSize.LARGE)
147 run_js("console.error(traceback_msg)", traceback_msg='Internal Server Error\n' + traceback_msg)
148 else:
149 toast(toast_msg, duration=1, color='error')
150 except Exception:
151 pass
152
153 def register_callback(self, callback, **options):
154 """ 向Session注册一个回调函数,返回回调id

Callers 4

callback_coroMethod · 0.80
stepMethod · 0.80
main_taskMethod · 0.80
runMethod · 0.80

Calls 4

popupFunction · 0.85
put_errorFunction · 0.85
run_jsFunction · 0.85
toastFunction · 0.85

Tested by

no test coverage detected