Created
June 12, 2012 09:58
-
-
Save sivaprasadreddy/2916667 to your computer and use it in GitHub Desktop.
RESTEasy Demo Custom Exceptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ResourceNotFoundException.java | |
*/ | |
package com.sivalabs.resteasydemo; | |
public class ResourceNotFoundException extends RuntimeException | |
{ | |
private static final long serialVersionUID = 1L; | |
public ResourceNotFoundException(String msg) | |
{ | |
super(msg); | |
} | |
} | |
/** | |
* ApplicationException.java | |
*/ | |
package com.sivalabs.resteasydemo; | |
import java.io.PrintWriter; | |
import java.io.StringWriter; | |
public class ApplicationException extends RuntimeException | |
{ | |
private static final long serialVersionUID = 1L; | |
public ApplicationException() | |
{ | |
super(); | |
} | |
public ApplicationException(String message, Throwable cause) | |
{ | |
super(message, cause); | |
} | |
public ApplicationException(Throwable cause) | |
{ | |
super(cause); | |
} | |
public ApplicationException(String msg) | |
{ | |
super(msg); | |
} | |
public String getInternalErrorMessage() | |
{ | |
Throwable cause = this.getCause(); | |
if(cause != null) | |
{ | |
StringWriter sw = new StringWriter(); | |
PrintWriter pw = new PrintWriter(sw); | |
cause.printStackTrace(pw); | |
return sw.toString(); | |
} | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment