Polishing contribution

Closes gh-35758
This commit is contained in:
rstoyanchev
2025-12-10 18:17:12 +00:00
parent e99791f289
commit 0eefac21c9
5 changed files with 15 additions and 4 deletions
@@ -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)
@@ -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 + ".");
}
@@ -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");
}
}
@@ -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 };
}
}