Skip to content

Commit 4071cd6

Browse files
committed
Changed: Exception handlers now search through superclasses.
1 parent d5b5e87 commit 4071cd6

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

docs/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ Small (C) Black Rook Software 2020
33
by Matt Tropiano et al. (see AUTHORS.txt)
44

55

6+
Changed in 1.5.4
7+
----------------
8+
9+
- `Changed` Exception handlers now search through superclasses for matching handlers.
10+
11+
612
Changed in 1.5.3
713
----------------
814

src/main/java/com/blackrook/small/SmallEnvironment.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,12 @@ public boolean handleView(HttpServletRequest request, HttpServletResponse respon
608608
public <T extends Throwable> boolean handleException(HttpServletRequest request, HttpServletResponse response, T throwable)
609609
{
610610
ExceptionHandler<T> handler;
611-
if ((handler = (ExceptionHandler<T>)exceptionHandlerMap.get(throwable.getClass())) != null)
611+
Class<?> exceptionClass = throwable.getClass();
612+
613+
while ((handler = (ExceptionHandler<T>)exceptionHandlerMap.get(exceptionClass)) == null && exceptionClass != Object.class)
614+
exceptionClass = exceptionClass.getSuperclass();
615+
616+
if (handler != null)
612617
{
613618
handler.handleException(request, response, throwable);
614619
return true;

0 commit comments

Comments
 (0)