summaryrefslogtreecommitdiff
path: root/src/object.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2012-04-26 15:05:07 +0200
committerCarlos Martín Nieto <carlos@cmartin.tk>2012-04-26 15:38:42 +0200
commit3aa351ea0fa0d9e8d155801cdac1e83d3b1717c1 (patch)
tree9b2d8994245744ca0d2c2d07ef2d61e420451172 /src/object.c
parenteb3d71a5bcd78cb4840e62194e8998141508af88 (diff)
downloadlibgit2-3aa351ea0fa0d9e8d155801cdac1e83d3b1717c1.tar.gz
error handling: move the missing parts over to the new error handling
Diffstat (limited to 'src/object.c')
-rw-r--r--src/object.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/object.c b/src/object.c
index bb27f71c1..979fb40ca 100644
--- a/src/object.c
+++ b/src/object.c
@@ -68,7 +68,8 @@ static int create_object(git_object **object_out, git_otype type)
break;
default:
- return git__throw(GIT_EINVALIDTYPE, "The given type is invalid");
+ giterr_set(GITERR_INVALID, "The given type is invalid");
+ return -1;
}
object->type = type;
@@ -92,8 +93,7 @@ int git_object_lookup_prefix(
assert(repo && object_out && id);
if (len < GIT_OID_MINPREFIXLEN)
- return git__throw(GIT_EAMBIGUOUS,
- "Failed to lookup object. Prefix length is lower than %d.", GIT_OID_MINPREFIXLEN);
+ return GIT_EAMBIGUOUS;
error = git_repository_odb__weakptr(&odb, repo);
if (error < GIT_SUCCESS)
@@ -110,13 +110,12 @@ int git_object_lookup_prefix(
if (object != NULL) {
if (type != GIT_OBJ_ANY && type != object->type) {
git_object_free(object);
- return git__throw(GIT_EINVALIDTYPE,
- "Failed to lookup object. "
- "The given type does not match the type on the ODB");
+ giterr_set(GITERR_INVALID, "The given type does not match the type in ODB");
+ return -1;
}
*object_out = object;
- return GIT_SUCCESS;
+ return 0;
}
/* Object was not found in the cache, let's explore the backends.
@@ -147,18 +146,19 @@ int git_object_lookup_prefix(
error = git_odb_read_prefix(&odb_obj, odb, &short_oid, len);
}
- if (error < GIT_SUCCESS)
- return git__rethrow(error, "Failed to lookup object");
+ if (error < 0)
+ return -1;
if (type != GIT_OBJ_ANY && type != odb_obj->raw.type) {
git_odb_object_free(odb_obj);
- return git__throw(GIT_EINVALIDTYPE, "Failed to lookup object. The given type does not match the type on the ODB");
+ giterr_set(GITERR_INVALID, "The given type does not match the type on the ODB");
+ return -1;
}
type = odb_obj->raw.type;
- if ((error = create_object(&object, type)) < GIT_SUCCESS)
- return git__rethrow(error, "Failed to lookup object");
+ if (create_object(&object, type) < 0)
+ return -1;
/* Initialize parent object */
git_oid_cpy(&object->cached.oid, &odb_obj->cached.oid);
@@ -187,13 +187,13 @@ int git_object_lookup_prefix(
git_odb_object_free(odb_obj);
- if (error < GIT_SUCCESS) {
+ if (error < 0) {
git_object__free(object);
- return git__rethrow(error, "Failed to lookup object");
+ return -1;
}
*object_out = git_cache_try_store(&repo->objects, object);
- return GIT_SUCCESS;
+ return 0;
}
int git_object_lookup(git_object **object_out, git_repository *repo, const git_oid *id, git_otype type) {