diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2021-04-30 16:51:46 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2021-04-30 16:51:46 +0200 |
commit | 1fea19bcc7227678fec9a6bce833a28f4c649c81 (patch) | |
tree | 76911f7495e6dd57e85b6b2bb867075cc3c22ed3 /container-core | |
parent | 5aef2726baf388ccd03e811800ba88ffbab86f8d (diff) |
More details with 404 and 405
Diffstat (limited to 'container-core')
-rw-r--r-- | container-core/src/main/java/com/yahoo/restapi/RestApiException.java | 4 | ||||
-rw-r--r-- | container-core/src/main/java/com/yahoo/restapi/RestApiImpl.java | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/container-core/src/main/java/com/yahoo/restapi/RestApiException.java b/container-core/src/main/java/com/yahoo/restapi/RestApiException.java index d9da320499f..68e46a3a9b8 100644 --- a/container-core/src/main/java/com/yahoo/restapi/RestApiException.java +++ b/container-core/src/main/java/com/yahoo/restapi/RestApiException.java @@ -42,6 +42,7 @@ public class RestApiException extends RuntimeException { public static class NotFound extends RestApiException { public NotFound() { this(null, null); } + public NotFound(HttpRequest request) { this("Nothing at '" + request.getUri().getRawPath() + "'", null); } public NotFound(Throwable cause) { this(cause.getMessage(), cause); } public NotFound(String message) { this(message, null); } public NotFound(String message, Throwable cause) { super(ErrorResponse::notFoundError, message, cause); } @@ -50,7 +51,8 @@ public class RestApiException extends RuntimeException { public static class MethodNotAllowed extends RestApiException { public MethodNotAllowed() { super(ErrorResponse::methodNotAllowed, "Method not allowed", null); } public MethodNotAllowed(HttpRequest request) { - super(ErrorResponse::methodNotAllowed, "Method '" + request.getMethod().name() + "' is not allowed", null); + super(ErrorResponse::methodNotAllowed, "Method '" + request.getMethod().name() + "' is not allowed at '" + + request.getUri().getRawPath() + "'", null); } } diff --git a/container-core/src/main/java/com/yahoo/restapi/RestApiImpl.java b/container-core/src/main/java/com/yahoo/restapi/RestApiImpl.java index 71fde8a9dbf..e5da3e52165 100644 --- a/container-core/src/main/java/com/yahoo/restapi/RestApiImpl.java +++ b/container-core/src/main/java/com/yahoo/restapi/RestApiImpl.java @@ -144,7 +144,7 @@ class RestApiImpl implements RestApi { private static Route createDefaultRoute() { RouteBuilder routeBuilder = new RouteBuilderImpl("{*}") .defaultHandler(context -> { - throw new RestApiException.NotFound(); + throw new RestApiException.NotFound(context.request()); }); return ((RouteBuilderImpl)routeBuilder).build(); } |