8000 [WIP] OdbBackend: Python subclassing by ddevault · Pull Request #948 · libgit2/pygit2 · GitHub
[go: up one dir, main page]

Skip to content

[WIP] OdbBackend: Python subclassing #948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Dec 21, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Introduce git_error_for_exc
  • Loading branch information
ddevault committed Dec 3, 2019
commit 4ca68f7d11a1a627a73b59ccc0515979bf944e34
17 changes: 17 additions & 0 deletions src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,20 @@ Error_type_error(const char *format, PyObject *value)
PyErr_Format(PyExc_TypeError, format, Py_TYPE(value)->tp_name);
return NULL;
}

int
git_error_for_exc()
{
PyObject *err;
if ((err = PyErr_Occurred()) != NULL) {
if (PyErr_GivenExceptionMatches(err, PyExc_KeyError)) {
return GIT_ENOTFOUND;
}
if (PyErr_GivenExceptionMatches(err, PyExc_ValueError)) {
return GIT_EINVALID;
}
/* TODO: others? */
return GIT_EUSER;
}
return 0;
}
1 change: 1 addition & 0 deletions src/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ PyObject* Error_set_exc(PyObject* exception);
PyObject* Error_set_str(int err, const char *str);
PyObject* Error_set_oid(int err, const git_oid *oid, size_t len);
PyObject* Error_type_error(const char *format, PyObject *value);
int git_error_for_exc();

#endif
0