MCPcopy Create free account
hub / github.com/libgit2/pygit2 / git_error_for_exc

Function git_error_for_exc

src/error.c:138–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138int
139git_error_for_exc(void)
140{
141 PyObject *err = PyErr_Occurred();
142 if (err) {
143 // FIXME Here we're masking exception, if the Python implementation has
144 // a genuine Key or Value error. We should have an explicit way for the
145 // Python callbacks to signal ENOTFOUND (and EAMBIGUOUS?)
146
147 // Not found is an expected condition (the ODB will try with the next
148 // backend), so we clear the exception.
149 if (PyErr_GivenExceptionMatches(err, PyExc_KeyError)) {
150 PyErr_Clear();
151 return GIT_ENOTFOUND;
152 }
153
154 if (PyErr_GivenExceptionMatches(err, PyExc_ValueError))
155 return GIT_EAMBIGUOUS;
156
157 return GIT_EUSER;
158 }
159
160 return 0;
161}

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…