mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +00:00
Polishing contribution
Closes gh-35758
This commit is contained in:
@@ -135,6 +135,10 @@ Message codes and arguments for each error are also resolved via `MessageSource`
|
||||
| `+{0}+` the list of global errors, `+{1}+` the list of field errors.
|
||||
Message codes and arguments for each error are also resolved via `MessageSource`.
|
||||
|
||||
| `NoResourceFoundException`
|
||||
| (default)
|
||||
| `+{0}+` the request path (or portion of) used to find a resource
|
||||
|
||||
|===
|
||||
|
||||
NOTE: Unlike other exceptions, the message arguments for
|
||||
|
||||
@@ -171,7 +171,7 @@ Message codes and arguments for each error are also resolved via `MessageSource`
|
||||
|
||||
| `NoResourceFoundException`
|
||||
| (default)
|
||||
| `+{0}+` the resource
|
||||
| `+{0}+` the request path (or portion of) used to find a resource
|
||||
|
||||
| `TypeMismatchException`
|
||||
| (default)
|
||||
|
||||
+4
-2
@@ -31,9 +31,11 @@ import org.springframework.web.server.ResponseStatusException;
|
||||
@SuppressWarnings("serial")
|
||||
public class NoResourceFoundException extends ResponseStatusException {
|
||||
|
||||
|
||||
public NoResourceFoundException(URI uri, String resourcePath) {
|
||||
super(HttpStatus.NOT_FOUND, "No static resource " + resourcePath + " for request '" + uri + "'.");
|
||||
super(HttpStatus.NOT_FOUND,
|
||||
"No static resource " + resourcePath + " for request '" + uri + "'.",
|
||||
null, null, new Object[] { resourcePath});
|
||||
|
||||
setDetail("No static resource " + resourcePath + ".");
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -40,4 +40,9 @@ class NoResourceFoundExceptionTests {
|
||||
assertThat(noResourceFoundException.getBody().getDetail()).isEqualTo("No static resource /resource.");
|
||||
}
|
||||
|
||||
@Test
|
||||
void messageArgumentsShouldContainResourcePath() {
|
||||
var noResourceFoundException = new NoResourceFoundException(URI.create("/context/resource"), "/resource");
|
||||
assertThat(noResourceFoundException.getDetailMessageArguments()).containsExactly("/resource");
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -80,6 +80,6 @@ public class NoResourceFoundException extends ServletException implements ErrorR
|
||||
|
||||
@Override
|
||||
public Object[] getDetailMessageArguments() {
|
||||
return new String[]{this.resourcePath};
|
||||
return new String[] { this.resourcePath };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user