Throwable exceptions not declared in method signatures
Closed this issue · 6 comments
This makes it difficult to know which exceptions to catch. Some of these are very important such as https://github.com/terraframe/common-geo-registry-adapter/blob/master/java/common/src/main/java/org/commongeoregistry/adapter/http/ResponseProcessor.java#L7
This is also visible from the https://github.com/terraframe/common-geo-registry-adapter/blob/master/java/common/src/main/java/org/commongeoregistry/adapter/HttpRegistryClient.java
I am going to start documenting where we should probably throw exceptions:
-
In the Attribute.java type hierarchy, an invalid value exception needs to be thrown for the method:
public void fromJSON(JsonElement jValue, RegistryAdapter registry) -
AttributeTerm - Throw exception when termCode is not valid
public void setTermCode(String termCode)
public void addTerm(String termCode)
Question: is it sufficient to have some kind of InvalidValue exception or should we subclass that with additional exceptions for the specific attribute types? I would think an exception on an AttributeTerm could have some additional accessor methods that would return some information on the term that is invalid. Let me think about that.
is it sufficient to have some kind of InvalidValue exception
Yes, I think that an InvalidvalueException
would be OK
InvalidLoginException
SessionTimeoutException
RunwayExceptionDTO (DataNotFoundException) (on client.getGeoObjectByCode)
Ephraim would like to have checked java exceptions so that he knows when a exception may be expected and when he should have a try/catch.
I will add the following checked exceptions to most calls to the server:
- AuthenticationException - Invalid user credentials
- ServerResponseException - Server responded with an error to a request
- IOException - Error occurred when trying to communicate with the server
Fixed in version 0.3.3