Skip to content

Commit

Permalink
Rename catchAllErrorHandler to uncaughtErrorHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
code-brazier committed Jul 26, 2024
1 parent d98df02 commit 803ad18
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion vertx-web/src/main/java/io/vertx/ext/web/Router.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ static Router router(Vertx vertx) {
* @return a reference to this, so the API can be used fluently
*/
@Fluent
Router catchAllErrorHandler(Handler<RoutingContext> errorHandler);
Router uncaughtErrorHandler(Handler<RoutingContext> errorHandler);

/**
* Used to route a context to the router. Used for sub-routers. You wouldn't normally call this method directly.
Expand Down
4 changes: 2 additions & 2 deletions vertx-web/src/main/java/io/vertx/ext/web/impl/RouterImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ public synchronized Router errorHandler(int statusCode, Handler<RoutingContext>
}

@Override
public synchronized Router catchAllErrorHandler(Handler<RoutingContext> errorHandler) {
state = state.setCatchAllErrorHandler(errorHandler);
public synchronized Router uncaughtErrorHandler(Handler<RoutingContext> errorHandler) {
state = state.setUncaughtErrorHandler(errorHandler);
return this;
}

Expand Down
33 changes: 17 additions & 16 deletions vertx-web/src/main/java/io/vertx/ext/web/impl/RouterState.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ final class RouterState {
private final TreeSet<RouteImpl> routes;
private final int orderSequence;
private final Map<Integer, Handler<RoutingContext>> errorHandlers;
private final Handler<RoutingContext> catchAllErrorHandler;
private final Handler<RoutingContext> uncaughtErrorHandler;
private final Handler<Router> modifiedHandler;
private final AllowForwardHeaders allowForward;
private final Map<String, Object> metadata;

public RouterState(RouterImpl router, TreeSet<RouteImpl> routes, int orderSequence, Map<Integer, Handler<RoutingContext>> errorHandlers, final Handler<RoutingContext> catchAllErrorHandler, Handler<Router> modifiedHandler, AllowForwardHeaders allowForward, Map<String, Object> metadata) {
public RouterState(RouterImpl router, TreeSet<RouteImpl> routes, int orderSequence, Map<Integer, Handler<RoutingContext>> errorHandlers, final Handler<RoutingContext> uncaughtErrorHandler, Handler<Router> modifiedHandler, AllowForwardHeaders allowForward, Map<String, Object> metadata) {
this.router = router;
this.routes = routes;
this.orderSequence = orderSequence;
this.errorHandlers = errorHandlers;
this.catchAllErrorHandler = catchAllErrorHandler;
this.uncaughtErrorHandler = uncaughtErrorHandler;
this.modifiedHandler = modifiedHandler;
this.allowForward = allowForward;
this.metadata = metadata;
Expand Down Expand Up @@ -102,7 +102,7 @@ RouterState setRoutes(Set<RouteImpl> routes) {
new TreeSet<>(routeComparator),
this.orderSequence,
this.errorHandlers,
this.catchAllErrorHandler,
this.uncaughtErrorHandler,
this.modifiedHandler,
this.allowForward,
this.metadata);
Expand All @@ -123,7 +123,7 @@ RouterState addRoute(RouteImpl route) {
routes,
this.orderSequence,
this.errorHandlers,
this.catchAllErrorHandler,
this.uncaughtErrorHandler,
this.modifiedHandler,
this.allowForward,
this.metadata);
Expand All @@ -135,7 +135,8 @@ RouterState clearRoutes() {
new TreeSet<>(routeComparator),
this.orderSequence,
this.errorHandlers,
null, this.modifiedHandler,
null,
this.modifiedHandler,
this.allowForward,
this.metadata);
}
Expand All @@ -152,7 +153,7 @@ RouterState removeRoute(RouteImpl route) {
routes,
this.orderSequence,
this.errorHandlers,
this.catchAllErrorHandler,
this.uncaughtErrorHandler,
this.modifiedHandler,
this.allowForward,
this.metadata);
Expand All @@ -168,7 +169,7 @@ RouterState incrementOrderSequence() {
this.routes,
this.orderSequence + 1,
this.errorHandlers,
this.catchAllErrorHandler,
this.uncaughtErrorHandler,
this.modifiedHandler,
this.allowForward,
this.metadata);
Expand All @@ -180,7 +181,7 @@ RouterState setOrderSequence(int orderSequence) {
this.routes,
orderSequence,
this.errorHandlers,
this.catchAllErrorHandler,
this.uncaughtErrorHandler,
this.modifiedHandler,
this.allowForward,
this.metadata);
Expand All @@ -196,7 +197,7 @@ RouterState setErrorHandlers(Map<Integer, Handler<RoutingContext>> errorHandlers
this.routes,
this.orderSequence,
errorHandlers,
this.catchAllErrorHandler,
this.uncaughtErrorHandler,
this.modifiedHandler,
this.allowForward,
this.metadata);
Expand All @@ -209,7 +210,7 @@ Handler<RoutingContext> getErrorHandler(int errorCode) {
return errorHandler;
}
}
return catchAllErrorHandler;
return uncaughtErrorHandler;
}

RouterState putErrorHandler(int errorCode, Handler<RoutingContext> errorHandler) {
Expand All @@ -218,7 +219,7 @@ RouterState putErrorHandler(int errorCode, Handler<RoutingContext> errorHandler)
this.routes,
this.orderSequence,
this.errorHandlers == null ? new HashMap<>() : new HashMap<>(errorHandlers),
this.catchAllErrorHandler,
this.uncaughtErrorHandler,
this.modifiedHandler,
this.allowForward,
this.metadata);
Expand All @@ -227,7 +228,7 @@ RouterState putErrorHandler(int errorCode, Handler<RoutingContext> errorHandler)
return newState;
}

RouterState setCatchAllErrorHandler(Handler<RoutingContext> errorHandler) {
RouterState setUncaughtErrorHandler(Handler<RoutingContext> errorHandler) {
return new RouterState(
this.router,
this.routes,
Expand All @@ -249,7 +250,7 @@ public RouterState setModifiedHandler(Handler<Router> modifiedHandler) {
this.routes,
this.orderSequence,
this.errorHandlers,
this.catchAllErrorHandler,
this.uncaughtErrorHandler,
modifiedHandler,
this.allowForward,
this.metadata);
Expand All @@ -261,7 +262,7 @@ public RouterState setAllowForward(AllowForwardHeaders allow) {
this.routes,
this.orderSequence,
this.errorHandlers,
this.catchAllErrorHandler,
this.uncaughtErrorHandler,
this.modifiedHandler,
allow,
this.metadata);
Expand All @@ -283,7 +284,7 @@ public RouterState putMetadata(String key, Object value) {
this.routes,
this.orderSequence,
this.errorHandlers,
this.catchAllErrorHandler,
this.uncaughtErrorHandler,
this.modifiedHandler,
this.allowForward,
Collections.unmodifiableMap(metadata));
Expand Down
4 changes: 2 additions & 2 deletions vertx-web/src/test/java/io/vertx/ext/web/RouterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3647,9 +3647,9 @@ public void testExtractCallee() throws Exception {
}

@Test
public void testCatchAllErrorHandler() throws Exception {
public void testUncaughtErrorHandler() throws Exception {
router.route().consumes("text/html").handler(rc -> rc.response().end());
router.catchAllErrorHandler(context -> context.response().setStatusCode(context.statusCode()).setStatusMessage("Dumb").end());
router.uncaughtErrorHandler(context -> context.response().setStatusCode(context.statusCode()).setStatusMessage("Dumb").end());

testRequestWithContentType(HttpMethod.GET, "/foo", "something/html", 415, "Dumb");
}
Expand Down

0 comments on commit 803ad18

Please sign in to comment.