Constant HandlerNotFoundException
This commit is contained in:
parent
1b3289d0d5
commit
623874b4d0
|
@ -173,10 +173,13 @@ public class DispatcherHandler implements HttpHandler, ApplicationContextAware {
|
|||
|
||||
private static class NotFoundHandlerMapping implements HandlerMapping {
|
||||
|
||||
@SuppressWarnings("ThrowableInstanceNeverThrown")
|
||||
private static final Exception HANDLER_NOT_FOUND_EXCEPTION = new HandlerNotFoundException();
|
||||
|
||||
|
||||
@Override
|
||||
public Publisher<Object> getHandler(ServerHttpRequest request) {
|
||||
return Publishers.error(new HandlerNotFoundException(request.getMethod(),
|
||||
request.getURI().getPath(), request.getHeaders()));
|
||||
return Publishers.error(HANDLER_NOT_FOUND_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,44 +16,15 @@
|
|||
package org.springframework.web.reactive;
|
||||
|
||||
import org.springframework.core.NestedRuntimeException;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
/**
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class HandlerNotFoundException extends NestedRuntimeException {
|
||||
|
||||
private final HttpMethod method;
|
||||
|
||||
private final String requestURL;
|
||||
|
||||
private final HttpHeaders headers;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for NoHandlerFoundException.
|
||||
* @param method the HTTP method
|
||||
* @param requestURL the HTTP request URL
|
||||
* @param headers the HTTP request headers
|
||||
*/
|
||||
public HandlerNotFoundException(HttpMethod method, String requestURL, HttpHeaders headers) {
|
||||
super("No handler found for " + method + " " + requestURL);
|
||||
this.method = method;
|
||||
this.requestURL = requestURL;
|
||||
this.headers = headers;
|
||||
public HandlerNotFoundException() {
|
||||
super("No handler found.");
|
||||
}
|
||||
|
||||
|
||||
public HttpMethod getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
||||
public String getRequestURL() {
|
||||
return this.requestURL;
|
||||
}
|
||||
|
||||
public HttpHeaders getHeaders() {
|
||||
return this.headers;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue