Skip to content

Commit

Permalink
display the traceback if an Exception is used as the message
Browse files Browse the repository at this point in the history
  • Loading branch information
jborbely committed Jul 31, 2017
1 parent 3647369 commit 1ef1ddb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions msl/qt/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
The following functions create a pop-up window to either notify the user of an
event that happened or to request information from the user.
"""
import traceback

from PyQt5 import QtWidgets, QtCore

from msl.qt import application
Expand All @@ -21,6 +23,8 @@ def critical(message, title=None):
If :obj:`None` then uses the text in the title bar of the active window.
"""
app, title = _get_app_and_title(title)
if isinstance(message, Exception):
message = traceback.format_exc()
QtWidgets.QMessageBox.critical(app.activeWindow(), title, str(message))


Expand All @@ -36,6 +40,8 @@ def warning(message, title=None):
If :obj:`None` then uses the text in the title bar of the active window.
"""
app, title = _get_app_and_title(title)
if isinstance(message, Exception):
message = traceback.format_exc()
QtWidgets.QMessageBox.warning(app.activeWindow(), title, str(message))


Expand All @@ -51,6 +57,8 @@ def information(message, title=None):
If :obj:`None` then uses the text in the title bar of the active window.
"""
app, title = _get_app_and_title(title)
if isinstance(message, Exception):
message = traceback.format_exc()
QtWidgets.QMessageBox.information(app.activeWindow(), title, str(message))


Expand Down

0 comments on commit 1ef1ddb

Please sign in to comment.