Skip to content

Commit ddd1f5a

Browse files
committed
fix: cleanup error message dialog
1 parent a96e421 commit ddd1f5a

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
0.17.3
2-
- fix: Drag'n'Drop to DCscope broken since 0.17.0 (#88)
2+
- fix: drag'n'drop to DCscope broken since 0.17.0 (#88)
33
- fix: show long resource names with elide-middle and tool tip (#89)
4+
- fix: error message dialog limited to traceback length of three
5+
- fix: copy error text to clipboard did not work in error message dialog
46
- enh: allow specifying collections in upload task files and via the API
57
- docs: increase warning threshold for max number of resources to 1000
68
(CKAN 2.11.3 handles datasets with many resources much better)

dcoraid/gui/main.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,13 @@ def excepthook(etype, value, trace):
265265
call last)``.
266266
"""
267267
vinfo = f"Unhandled exception in DCOR-Aid version {__version__}:\n"
268-
tmp = tb.format_exception(etype, value, trace)
269-
exception = "".join([vinfo] + tmp)
268+
exc_long = "".join([vinfo] + tb.format_exception(etype, value, trace))
269+
exc_short = "".join([vinfo] + tb.format_exception(
270+
etype, value, trace, limit=3))
270271

271272
# log the exception
272273
logger = logging.getLogger(__name__)
273-
logger.error(exception)
274+
logger.error(exc_long)
274275

275276
# Test connectivity
276277
if etype is APIOutdatedError:
@@ -283,16 +284,20 @@ def excepthook(etype, value, trace):
283284

284285
errorbox = QtWidgets.QMessageBox()
285286
errorbox.setIcon(QtWidgets.QMessageBox.Icon.Critical)
287+
copy_button = QtWidgets.QPushButton('Copy message to clipboard and close')
288+
copy_button.clicked.connect(lambda: copy_text_to_clipboard(exc_long))
286289
errorbox.addButton(QtWidgets.QPushButton('Close'),
287290
QtWidgets.QMessageBox.ButtonRole.YesRole)
288-
errorbox.addButton(QtWidgets.QPushButton(
289-
'Copy text && Close'), QtWidgets.QMessageBox.ButtonRole.NoRole)
290-
errorbox.setText(exception)
291-
ret = errorbox.exec()
292-
if ret == 1:
293-
cb = QtWidgets.QApplication.clipboard()
294-
cb.clear(mode=cb.Clipboard)
295-
cb.setText(exception)
291+
errorbox.addButton(copy_button, QtWidgets.QMessageBox.ButtonRole.NoRole)
292+
errorbox.setDetailedText(exc_long)
293+
errorbox.setText(exc_short)
294+
errorbox.exec()
295+
296+
297+
def copy_text_to_clipboard(text):
298+
cb = QtWidgets.QApplication.clipboard()
299+
cb.clear()
300+
cb.setText(text)
296301

297302

298303
# Make Ctr+C close the app

0 commit comments

Comments
 (0)