what i want to achieve is add Generic in my exception class which is looked like this before :
@ResponseStatus(HttpStatus.NOT_MODIFIED)
public class ResourceGeneralErrorTest extends RuntimeException {
public ResourceGeneralErrorTest(String message){
super(message);
}
}
and i use it like this :
throw new ResourceGeneralError("Some error string " + errorTransDoMsg.toString());
but i only can pass string value inside this class. I want to pass Object class in this, so i try to add this :
@ResponseStatus(HttpStatus.NOT_MODIFIED)
public class ResourceGeneralErrorTest<T> extends RuntimeException {
private T data;
public ResourceGeneralErrorTest(String message){
super(message);
}
}
which is give me error when i extends the RuntimeException class, here is the error message Generic class may not extend 'java.lang.Throwable'
how can i keep extends RuntimeException and i can pass some object into it with my String message?