自定义异常变成了UndeclaredThrowableException
我自定义一个异常继承java.lang.Exception,程序抛出这个异常之后变成了UndeclaredThrowableException。有人知道是为什么吗?
代码如下:
public class ValidationException extends java.lang.Exception {
private static final long serialVersionUID = 3524065421516830204L;
public ValidationException(String message) {
super(message);
}
}
捕获异常代码:
public Response toResponse(Exception exception) {
if (exception instanceof ValidationException) {
return ResponseHelper.validateFailed(exception.getMessage());
}