Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sivaprasadreddy/2916667 to your computer and use it in GitHub Desktop.
Save sivaprasadreddy/2916667 to your computer and use it in GitHub Desktop.
RESTEasy Demo Custom Exceptions
/**
* 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