added Error_set_exc() for throwing individual Exceptions

This commit is contained in:
Nico von Geyso
2012-11-19 23:12:12 +01:00
parent b2359200bb
commit 64bb6efc2b
2 changed files with 12 additions and 0 deletions

View File

@@ -34,6 +34,7 @@
PyObject* Error_type(int type);
PyObject* Error_set(int err);
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);

View File

@@ -92,6 +92,17 @@ PyObject* Error_set(int err)
return NULL;
}
PyObject* Error_set_exc(PyObject* exception)
{
const git_error* error = giterr_last();
char* message = (error == NULL) ?
"(No error information given)" : error->message;
PyErr_SetString(exception, message);
return NULL;
}
PyObject* Error_set_str(int err, const char *str)
{
const git_error* error;