Add methods for static resolution of @ExceptionHandler

This commit is contained in:
Rossen Stoyanchev
2013-12-09 08:19:17 -05:00
parent 6078c27e60
commit 5f38996cd6
2 changed files with 29 additions and 2 deletions

View File

@@ -114,7 +114,16 @@ public class ExceptionHandlerMethodResolver {
* @return a method to handle the exception or {@code null}
*/
public Method resolveMethod(Exception exception) {
Class<? extends Exception> exceptionType = exception.getClass();
return resolveMethodByExceptionType(exception.getClass());
}
/**
* Find a method to handle the given exception type. This can be useful if
* an Exception instance is not available (example for tools).
* @param exceptionType the exception type
* @return a method to handle the exception or {@code null}
*/
public Method resolveMethodByExceptionType(Class<? extends Exception> exceptionType) {
Method method = this.exceptionLookupCache.get(exceptionType);
if (method == null) {
method = getMappedMethod(exceptionType);