Skip to content

Commit

Permalink
make python error handling translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Oct 23, 2015
1 parent e5ad57b commit b65b595
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions python/utils.py
Expand Up @@ -91,16 +91,15 @@ def showException(type, value, tb, msg, messagebar=False):
# Grab the first message bar for now
bar = widgets[0]


item = bar.currentItem()
if item and item.property("Error") == msg:
# Return of we already have a message with the same error message
return

widget = bar.createMessage(title, msg + " See message log (Python Error) for more details.")
widget = bar.createMessage(title, msg + " " + QCoreApplication.translate("Python", "See message log (Python Error) for more details."))
widget.setProperty("Error", msg)
stackbutton = QPushButton("Stack trace", pressed=functools.partial(open_stack_dialog, type, value, tb, msg))
button = QPushButton("View message log", pressed=show_message_log)
stackbutton = QPushButton(QCoreApplication.translate("Python", "Stack trace"), pressed=functools.partial(open_stack_dialog, type, value, tb, msg))
button = QPushButton(QCoreApplication.translate("Python", "View message log"), pressed=show_message_log)
widget.layout().addWidget(stackbutton)
widget.layout().addWidget(button)
bar.pushWidget(widget, QgsMessageBar.WARNING)
Expand All @@ -121,7 +120,7 @@ def open_stack_dialog(type, value, tb, msg, pop_error=True):
msg = QCoreApplication.translate('Python', 'An error has occured while executing Python code:')

# TODO Move this to a template HTML file
txt = '''<font color="red"><b>{msg}</b></font>
txt = u'''<font color="red"><b>{msg}</b></font>
<br>
<h3>{main_error}</h3>
<pre>
Expand Down Expand Up @@ -158,7 +157,7 @@ def open_stack_dialog(type, value, tb, msg, pop_error=True):
qgisrelease=QGis.QGIS_RELEASE_NAME,
devversion=QGis.QGIS_DEV_VERSION,
pypath_label=pypath_label,
pypath="".join("<li>{}</li>".format(path) for path in sys.path))
pypath=u"".join(u"<li>{}</li>".format(path) for path in sys.path))

txt = txt.replace(' ', '&nbsp; ') # preserve whitespaces for nicer output

Expand Down

0 comments on commit b65b595

Please sign in to comment.