Hello Jersey Users ,
I am using JDK 1.5 and Jersey version 1.1.1-ea for
restful service development. We have a Flex client which consumes the
restful services. I have used the Jersey exception framework
(WebApplicationException) to propagate exceptions to Flex client.
The exceptions thrown from the application are propagated as HTTP faults
with the status code 500. If I want to include additional
information(for example application error code) as a part of the
propagated exception , is there a way this can be achieved ?
In the code below "CustomException" is the custom exception framework
used in our application. Can the "applicationErrCode" (defined below) be
propagated to the client as a part of HTTP Fault.
public class RestfulServiceException extends WebApplicationException
implements CustomException {
private static final long serialVersionUID = 1387449832483248304L;
public String message;
public Response.Status httpStatus;
/**
* Here the err code should follow the format
*/
public String applicationErrCode;
public String action;
public String severity;
public String errorCause;
public RestfulServiceException (){
super(500);
httpStatus = Response.Status.INTERNAL_SERVER_ERROR;
;
}
public RestfulServiceException (CustomException cse){
this.action= cse.getAction();
this.applicationErrCode = cse.getErrorCode();
this.errorCause = cse.getErrorCause();
this.httpStatus = Response.Status.INTERNAL_SERVER_ERROR ;
this.message = cse.getMessage();
this.severity = cse.getSeverity();
}
Thank you,
Suchitha.