suggest ExceptionFilter should't change the RuntimeException again
// directly throw if it's checked exception
if (!(exception instanceof RuntimeException) && (exception instanceof Exception)) {
return;
}
//ellipsis some code
// otherwise, wrap with RuntimeException and throw back to the client
appResponse.setException(new RuntimeException(StringUtils.toString(exception)));
on this code it change the Exception
I don't know what purpose of change the Exception,especially when this Exception instanceof RuntimeException,It just wrap it again
If you want to send some message by Exception,a instanceof of RuntimeException is a good choice.
It don't need to declare on every method,but catch on the global exception handler
For example,if you use java proxy,it auto generate a class like that if you has no exception appears in the signature:
try {
super.h.invoke(this, m3, (Object[])null);
} catch (RuntimeException | Error var2) {
throw var2;
} catch (Throwable var3) {
throw new UndeclaredThrowableException(var3);
}
suggest ExceptionFilter should't change the RuntimeException again
// directly throw if it's checked exception if (!(exception instanceof RuntimeException) && (exception instanceof Exception)) { return; } //ellipsis some code // otherwise, wrap with RuntimeException and throw back to the client appResponse.setException(new RuntimeException(StringUtils.toString(exception)));
on this code it change the Exception I don't know what purpose of change the Exception,especially when this Exception instanceof RuntimeException,It just wrap it again If you want to send some message by Exception,a instanceof of RuntimeException is a good choice. It don't need to declare on every method,but catch on the global exception handler For example,if you use java proxy,it auto generate a class like that if you has no exception appears in the signature: try { super.h.invoke(this, m3, (Object[])null); } catch (RuntimeException | Error var2) { throw var2; } catch (Throwable var3) { throw new UndeclaredThrowableException(var3); }