Skip to content

Commit e121b7e

Browse files
authored
rename exception method (#77)
1 parent 643202a commit e121b7e

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

avaje-jex/src/main/java/io/avaje/jex/DefaultRouting.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public Routing addAll(Collection<Routing.HttpService> routes) {
6565
}
6666

6767
@Override
68-
public <T extends Exception> Routing exception(Class<T> type, ExceptionHandler<T> handler) {
68+
public <T extends Exception> Routing error(Class<T> type, ExceptionHandler<T> handler) {
6969
exceptionHandlers.put(type, handler);
7070
return this;
7171
}

avaje-jex/src/main/java/io/avaje/jex/Routing.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public sealed interface Routing permits DefaultRouting {
4747
Routing withRoles(Role... permittedRoles);
4848

4949
/** Register an exception handler for the given exception type. */
50-
<T extends Exception> Routing exception(Class<T> exceptionClass, ExceptionHandler<T> handler);
50+
<T extends Exception> Routing error(Class<T> exceptionClass, ExceptionHandler<T> handler);
5151

5252
/** Add a group of route handlers with a common path prefix. */
5353
Routing path(String path, Group group);

avaje-jex/src/test/java/io/avaje/jex/DefaultErrorHandlingTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class DefaultErrorHandlingTest {
1717
void exception() {
1818

1919
Routing router = new DefaultRouting();
20-
router.exception(RuntimeException.class, rt);
20+
router.error(RuntimeException.class, rt);
2121

2222
var handling = new ExceptionManager(router.errorHandlers());
2323

@@ -29,8 +29,8 @@ void exception() {
2929
@Test
3030
void exception_expect_highestMatch() {
3131
Routing router = new DefaultRouting();
32-
router.exception(RuntimeException.class, rt);
33-
router.exception(IllegalStateException.class, ise);
32+
router.error(RuntimeException.class, rt);
33+
router.error(IllegalStateException.class, ise);
3434

3535
var handling = new ExceptionManager(router.errorHandlers());
3636

avaje-jex/src/test/java/io/avaje/jex/jdk/ExceptionManagerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ static TestPair init() {
3030
.get("/fiveHundred", ctx -> {
3131
throw new IllegalArgumentException("Bar");
3232
})
33-
.exception(NullPointerException.class, (exception, ctx) -> ctx.text("npe"))
34-
.exception(IllegalStateException.class, (exception, ctx) -> ctx.status(222).text("Handled IllegalStateException|" + exception.getMessage())));
33+
.error(NullPointerException.class, (exception, ctx) -> ctx.text("npe"))
34+
.error(IllegalStateException.class, (exception, ctx) -> ctx.status(222).text("Handled IllegalStateException|" + exception.getMessage())));
3535

3636
return TestPair.create(app);
3737
}

0 commit comments

Comments
 (0)