MCPcopy Create free account
hub / github.com/apache/arrow / MapPyError

Function MapPyError

python/pyarrow/src/arrow/python/common.cc:63–85  ·  view source on GitHub ↗

Try to match the Python exception type with an appropriate Status code

Source from the content-addressed store, hash-verified

61
62// Try to match the Python exception type with an appropriate Status code
63StatusCode MapPyError(PyObject* exc_type) {
64 StatusCode code;
65
66 if (PyErr_GivenExceptionMatches(exc_type, PyExc_MemoryError)) {
67 code = StatusCode::OutOfMemory;
68 } else if (PyErr_GivenExceptionMatches(exc_type, PyExc_IndexError)) {
69 code = StatusCode::IndexError;
70 } else if (PyErr_GivenExceptionMatches(exc_type, PyExc_KeyError)) {
71 code = StatusCode::KeyError;
72 } else if (PyErr_GivenExceptionMatches(exc_type, PyExc_TypeError)) {
73 code = StatusCode::TypeError;
74 } else if (PyErr_GivenExceptionMatches(exc_type, PyExc_ValueError) ||
75 PyErr_GivenExceptionMatches(exc_type, PyExc_OverflowError)) {
76 code = StatusCode::Invalid;
77 } else if (PyErr_GivenExceptionMatches(exc_type, PyExc_EnvironmentError)) {
78 code = StatusCode::IOError;
79 } else if (PyErr_GivenExceptionMatches(exc_type, PyExc_NotImplementedError)) {
80 code = StatusCode::NotImplemented;
81 } else {
82 code = StatusCode::UnknownError;
83 }
84 return code;
85}
86
87// PythonErrorDetail indicates a Python exception was raised.
88class PythonErrorDetail : public StatusDetail {

Callers 1

ConvertPyErrorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected