Skip to content

Commit 5242db7

Browse files
committed
no traceback expose to user when debug=False
1 parent 986d6ec commit 5242db7

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

pywebio/session/base.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,20 +134,19 @@ def on_task_exception(self):
134134
from . import run_js
135135
from . import info as session_info
136136

137-
logger.exception('Error')
138-
139-
toast_msg = "应用发生内部错误" if 'zh' in session_info.user_language else "An internal error occurred in the application"
140-
141-
e_type, e_value, e_tb = sys.exc_info()
142-
lines = traceback.format_exception(e_type, e_value, e_tb)
143-
traceback_msg = ''.join(lines)
137+
# log exception in server
138+
logger.exception('Unhandled error in pywebio app')
144139

145140
try:
141+
toast_msg = "应用发生内部错误" if 'zh' in session_info.user_language else "An internal error occurred in the application"
146142
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)
147146
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)
148148
else:
149149
toast(toast_msg, duration=1, color='error')
150-
run_js("console.error(traceback_msg)", traceback_msg='Internal Server Error\n' + traceback_msg)
151150
except Exception:
152151
pass
153152

0 commit comments

Comments
 (0)