I want to create some generic abstract class:
public abstract class SomeDomainValidationException<E extends Enum<E>> extends ValidationException {
private final E hint;
public SomeDomainValidationException(String message, E hint) {
super(message);
this.hint = hint;
}
}
where:
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
public class ValidationException extends RuntimeException {
public ValidationException(String message) {
super(message);
}
}
I want to group different types of exceptions in my code, eg I want to create different types of exceptions like:
WarehouseMatchingException
extends SomeDomainValidationException<WarehouseWrongDatesEnum>
but of course I can't because generic class may not extend 'java.lang.Throwable'
How to create generic class that represents different types of exceptions included in some enums like WarehouseWrongDatesEnum
?