Skip to content

Unpredictable behavior inside ArangoDBException #132

Closed
@ThomasJejkal

Description

@ThomasJejkal

Hi,

I'm using your driver inside a RESTful service, therefore the idea was to forward the error states coming from ArangoDB by wrapping them into WebApplicationExceptions.

Unfortunately, I recognized a problem which arises if the ArangoDBException is not produced using an ErrorEntity, e.g. when trying to insert a document with the wrong schema. In that case, accessing the response code as shown below fails with an NPE:

} catch (ArangoDBException ex) {
   LOGGER.error("Failed to perform query '" + query + "' due to a database error.", ex);
   throw new WebApplicationException(ex.getResponseCode());
}

This is caused by the fact, that the compiler does not complain about this code:

public int getResponseCode() {
	return entity != null ? entity.getCode() : null;
}

It would be great to have either different exceptions (probably, implementing this is quite expensive) or if ArangoDBException#getResponseCode() and ArangoDBException#getErrorNum() would return some primitive default value, e.g. -1

Thanks and regards,
Thomas

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions