MCPcopy Create free account
hub / github.com/baldurk/renderdoc / FetchException

Function FetchException

qrenderdoc/Code/pyrenderdoc/PythonContext.cpp:154–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154void FetchException(QString &typeStr, QString &valueStr, int &finalLine, QList<QString> &frames)
155{
156 PyObject *exObj = NULL, *valueObj = NULL, *tracebackObj = NULL;
157
158 PyErr_Fetch(&exObj, &valueObj, &tracebackObj);
159
160 PyErr_NormalizeException(&exObj, &valueObj, &tracebackObj);
161
162 if(exObj && PyType_Check(exObj))
163 {
164 PyTypeObject *type = (PyTypeObject *)exObj;
165
166 typeStr = QString::fromUtf8(type->tp_name);
167 }
168 else
169 {
170 typeStr = QString();
171 }
172
173 if(valueObj)
174 valueStr = ToQStr(valueObj);
175
176 if(tracebackObj)
177 {
178 PyObject *tracebackModule = PyImport_ImportModule("traceback");
179
180 if(tracebackModule)
181 {
182 PyObject *func = PyObject_SafeGetAttrString(tracebackModule, "format_tb");
183
184 if(func && PyCallable_Check(func))
185 {
186 PyObject *args = Py_BuildValue("(O)", tracebackObj);
187 PyObject *formattedTB = PyObject_CallObject(func, args);
188
189 PyTracebackObject *tb = (PyTracebackObject *)tracebackObj;
190
191 while(tb->tb_next)
192 tb = tb->tb_next;
193
194 finalLine = tb->tb_lineno;
195
196 if(formattedTB)
197 {
198 Py_ssize_t size = PyList_Size(formattedTB);
199 for(Py_ssize_t i = 0; i < size; i++)
200 {
201 PyObject *el = PyList_GetItem(formattedTB, i);
202
203 frames << ToQStr(el).trimmed();
204 }
205
206 Py_DecRef(formattedTB);
207 }
208
209 Py_DecRef(args);
210 }
211 else

Callers 4

PythonContextMethod · 0.85
LoadExtensionMethod · 0.85
executeStringMethod · 0.85
HandleExceptionFunction · 0.85

Calls 5

trimmedMethod · 0.80
ToQStrFunction · 0.70
fromUtf8Function · 0.50
QStringFunction · 0.50

Tested by

no test coverage detected