|
This post has NOT been accepted by the mailing list yet.
In my code I have an Exception that extends IllegalArgumentException:
public class InvalidDataSourceException extends IllegalArgumentException {
public InvalidDataSourceException(String message, Throwable cause) {
super(message, cause);
}
}
And in my Jersey REST web service, all errors are wrapped with a class RESTError so that all rest services can throw this same exception:
public class RESTError extends Throwable {
public RESTError(Throwable cause) {
super(cause);
}
}
So when the InvalidDataSourceException occurs, it is thrown as the cause of a RESTError:
throw new RESTError(invalidDataSourceException);
Then from another Java app, I call create a jersey client and call this service method, triggering the REST Error. Upon reading error status I attempt to readEntity(RESTError.class).
When I do this, the Exception cause is serialized to java.lang.Throwable, instead of my custom InvalidDataSourceException. It down-casted it. Why is that?
|