4 # |
4 # |
5 |
5 |
6 """ |
6 """ |
7 Module implementing the Exception Logger widget. |
7 Module implementing the Exception Logger widget. |
8 """ |
8 """ |
|
9 |
|
10 import contextlib |
9 |
11 |
10 from PyQt5.QtCore import pyqtSignal, Qt |
12 from PyQt5.QtCore import pyqtSignal, Qt |
11 from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QMenu |
13 from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QMenu |
12 |
14 |
13 from E5Gui.E5Application import e5App |
15 from E5Gui.E5Application import e5App |
28 """ |
30 """ |
29 Constructor |
31 Constructor |
30 |
32 |
31 @param parent the parent widget of this widget |
33 @param parent the parent widget of this widget |
32 """ |
34 """ |
33 super(ExceptionLogger, self).__init__(parent) |
35 super().__init__(parent) |
34 self.setObjectName("ExceptionLogger") |
36 self.setObjectName("ExceptionLogger") |
35 |
37 |
36 self.setWindowTitle(self.tr("Exceptions")) |
38 self.setWindowTitle(self.tr("Exceptions")) |
37 |
39 |
38 self.setWordWrap(True) |
40 self.setWordWrap(True) |
106 0, self.tr('{0}: An unhandled exception occured.' |
108 0, self.tr('{0}: An unhandled exception occured.' |
107 ' See the shell window for details.') |
109 ' See the shell window for details.') |
108 .format(debuggerId)) |
110 .format(debuggerId)) |
109 return |
111 return |
110 |
112 |
111 if not exceptionMessage: |
113 text = ( |
112 text = self.tr("{0}: {1}").format( |
114 self.tr("{0}: {1}").format(debuggerId, exceptionType) |
113 debuggerId, exceptionType) |
115 if not exceptionMessage else |
114 else: |
116 self.tr("{0}: {1}, {2}").format(debuggerId, exceptionType, |
115 text = self.tr("{0}: {1}, {2}").format( |
117 exceptionMessage) |
116 debuggerId, exceptionType, exceptionMessage) |
118 ) |
117 |
119 |
118 itm.setText(0, text) |
120 itm.setText(0, text) |
119 itm.setToolTip(0, text) |
121 itm.setToolTip(0, text) |
120 |
122 |
121 # now add the call stack, most recent call first |
123 # now add the call stack, most recent call first |
139 if itm.parent() is None: |
141 if itm.parent() is None: |
140 return |
142 return |
141 |
143 |
142 entry = itm.text(0) |
144 entry = itm.text(0) |
143 entryList = entry.split(",") |
145 entryList = entry.split(",") |
144 try: |
146 with contextlib.suppress(IndexError, ValueError): |
145 self.sourceFile.emit(entryList[0], int(entryList[1])) |
147 self.sourceFile.emit(entryList[0], int(entryList[1])) |
146 except (IndexError, ValueError): |
148 |
147 pass |
|
148 |
|
149 def __configure(self): |
149 def __configure(self): |
150 """ |
150 """ |
151 Private method to open the configuration dialog. |
151 Private method to open the configuration dialog. |
152 """ |
152 """ |
153 e5App().getObject("UserInterface").showPreferences( |
153 e5App().getObject("UserInterface").showPreferences( |