Undo constructor deprecation + polishing
This commit is contained in:
parent
30f1eee4d0
commit
ffe2ba4c7b
|
@ -65,19 +65,19 @@ public interface ErrorResponse {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a code to use to resolve the problem "detail" for this exception
|
* Return a code to use to resolve the problem "detail" for this exception
|
||||||
* through a {@link org.springframework.context.MessageSource}.
|
* through a {@link MessageSource}.
|
||||||
* <p>By default this is initialized via
|
* <p>By default this is initialized via
|
||||||
* {@link #getDefaultDetailMessageCode(Class, String)} but each exception
|
* {@link #getDefaultDetailMessageCode(Class, String)}.
|
||||||
* overrides this to provide relevant data that that can be expanded into
|
|
||||||
* placeholders within the message.
|
|
||||||
*/
|
*/
|
||||||
default String getDetailMessageCode() {
|
default String getDetailMessageCode() {
|
||||||
return getDefaultDetailMessageCode(getClass(), null);
|
return getDefaultDetailMessageCode(getClass(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the arguments to use to resolve the problem "detail" through a
|
* Return arguments to use along with a {@link #getDetailMessageCode()
|
||||||
* {@link MessageSource}.
|
* message code} to resolve the problem "detail" for this exception
|
||||||
|
* through a {@link MessageSource}. The arguments are expanded
|
||||||
|
* into placeholders of the message value, e.g. "Invalid content type {0}".
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
default Object[] getDetailMessageArguments() {
|
default Object[] getDetailMessageArguments() {
|
||||||
|
@ -86,10 +86,8 @@ public interface ErrorResponse {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Variant of {@link #getDetailMessageArguments()} that uses the given
|
* Variant of {@link #getDetailMessageArguments()} that uses the given
|
||||||
* {@link MessageSource} to resolve the message arguments.
|
* {@link MessageSource} for resolving the message argument values.
|
||||||
* <p>By default this delegates to {@link #getDetailMessageArguments()}
|
* This is useful for example to message codes from validation errors.
|
||||||
* by concrete implementations may override it, for example in order to
|
|
||||||
* resolve validation errors through a {@code MessageSource}.
|
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
default Object[] getDetailMessageArguments(MessageSource messageSource, Locale locale) {
|
default Object[] getDetailMessageArguments(MessageSource messageSource, Locale locale) {
|
||||||
|
|
|
@ -52,9 +52,7 @@ public class HttpRequestMethodNotSupportedException extends ServletException imp
|
||||||
/**
|
/**
|
||||||
* Create a new HttpRequestMethodNotSupportedException.
|
* Create a new HttpRequestMethodNotSupportedException.
|
||||||
* @param method the unsupported HTTP request method
|
* @param method the unsupported HTTP request method
|
||||||
* @deprecated 6.0 in favor of {@link #HttpRequestMethodNotSupportedException(String, Collection)}
|
|
||||||
*/
|
*/
|
||||||
@Deprecated(since = "6.0", forRemoval = true)
|
|
||||||
public HttpRequestMethodNotSupportedException(String method) {
|
public HttpRequestMethodNotSupportedException(String method) {
|
||||||
this(method, (String[]) null);
|
this(method, (String[]) null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,8 +111,8 @@ public class MethodArgumentNotValidException extends BindException implements Er
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert each given {@link ObjectError} to a single quote String, taking
|
* Convert each given {@link ObjectError} to a String in single quotes, taking
|
||||||
* either an error's default message as a first choice, or its error code.
|
* either the error's default message, or its error code.
|
||||||
* @since 6.0
|
* @since 6.0
|
||||||
*/
|
*/
|
||||||
public static List<String> errorsToStringList(List<? extends ObjectError> errors) {
|
public static List<String> errorsToStringList(List<? extends ObjectError> errors) {
|
||||||
|
@ -121,9 +121,9 @@ public class MethodArgumentNotValidException extends BindException implements Er
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Variant of {@link #errorsToStringList(List)} that uses the provided
|
* Variant of {@link #errorsToStringList(List)} that uses a
|
||||||
* {@link MessageSource} to resolve the error code, or otherwise fall
|
* {@link MessageSource} to resolve the message code of the error, or fall
|
||||||
* back on its default message.
|
* back on the error's default message.
|
||||||
* @since 6.0
|
* @since 6.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
|
|
|
@ -41,8 +41,8 @@ public class MissingRequestValueException extends ServletRequestBindingException
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with a message and a flag that indicates whether the value
|
* Constructor with a message and a flag that indicates whether a value
|
||||||
* was not completely missing but became was {@code null} after conversion.
|
* was present but became {@code null} after conversion.
|
||||||
*/
|
*/
|
||||||
public MissingRequestValueException(String msg, boolean missingAfterConversion) {
|
public MissingRequestValueException(String msg, boolean missingAfterConversion) {
|
||||||
super(msg);
|
super(msg);
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class UnsatisfiedServletRequestParameterException extends ServletRequestB
|
||||||
private static List<String> paramsToStringList(List<String[]> paramConditions) {
|
private static List<String> paramsToStringList(List<String[]> paramConditions) {
|
||||||
Assert.notEmpty(paramConditions, "Parameter conditions must not be empty");
|
Assert.notEmpty(paramConditions, "Parameter conditions must not be empty");
|
||||||
return paramConditions.stream()
|
return paramConditions.stream()
|
||||||
.map(c -> "\"" + StringUtils.arrayToDelimitedString(c, ", ") + "\"")
|
.map(condition -> "\"" + StringUtils.arrayToDelimitedString(condition, ", ") + "\"")
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,8 +80,8 @@ public class ResponseStatusException extends ErrorResponseException {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with a {@link org.springframework.context.MessageSource}
|
* Constructor with a message code and arguments for resolving the error
|
||||||
* code and arguments to resolve the detail message with.
|
* "detail" via {@link org.springframework.context.MessageSource}.
|
||||||
* @param status the HTTP status (required)
|
* @param status the HTTP status (required)
|
||||||
* @param reason the associated reason (optional)
|
* @param reason the associated reason (optional)
|
||||||
* @param cause a nested exception (optional)
|
* @param cause a nested exception (optional)
|
||||||
|
|
|
@ -57,8 +57,8 @@ public class ServerWebInputException extends ResponseStatusException {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with a {@link org.springframework.context.MessageSource} code
|
* Constructor with a message code and arguments for resolving the error
|
||||||
* and arguments to resolve the detail message with.
|
* "detail" via {@link org.springframework.context.MessageSource}.
|
||||||
* @since 6.0
|
* @since 6.0
|
||||||
*/
|
*/
|
||||||
protected ServerWebInputException(String reason, @Nullable MethodParameter parameter, @Nullable Throwable cause,
|
protected ServerWebInputException(String reason, @Nullable MethodParameter parameter, @Nullable Throwable cause,
|
||||||
|
|
Loading…
Reference in New Issue