Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ public static HttpClientErrorException create(@Nullable String message, HttpStat
case GONE -> message != null ?
new Gone(message, statusText, headers, body, charset) :
new Gone(statusText, headers, body, charset);
case PRECONDITION_FAILED -> message != null ?
new PreconditionFailed(message, statusText, headers, body, charset) :
new PreconditionFailed(statusText, headers, body, charset);
case UNSUPPORTED_MEDIA_TYPE -> message != null ?
new UnsupportedMediaType(message, statusText, headers, body, charset) :
new UnsupportedMediaType(statusText, headers, body, charset);
Expand Down Expand Up @@ -294,6 +297,22 @@ private Gone(String message, String statusText, HttpHeaders headers, byte @Nulla
}
}

/**
* {@link HttpClientErrorException} for status HTTP 412 Precondition Failed.
* @since 7.1
*/
@SuppressWarnings("serial")
public static final class PreconditionFailed extends HttpClientErrorException {

private PreconditionFailed(String statusText, HttpHeaders headers, byte @Nullable [] body, @Nullable Charset charset) {
super(HttpStatus.PRECONDITION_FAILED, statusText, headers, body, charset);
}

private PreconditionFailed(String message, String statusText, HttpHeaders headers, byte @Nullable [] body, @Nullable Charset charset) {
super(message, HttpStatus.PRECONDITION_FAILED, statusText, headers, body, charset);
}
}

/**
* {@link HttpClientErrorException} for status HTTP 415 Unsupported Media Type.
* @since 5.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,20 @@
import static org.springframework.http.HttpStatus.CONFLICT;
import static org.springframework.http.HttpStatus.FORBIDDEN;
import static org.springframework.http.HttpStatus.GATEWAY_TIMEOUT;
import static org.springframework.http.HttpStatus.GONE;
import static org.springframework.http.HttpStatus.HTTP_VERSION_NOT_SUPPORTED;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import static org.springframework.http.HttpStatus.I_AM_A_TEAPOT;
import static org.springframework.http.HttpStatus.METHOD_NOT_ALLOWED;
import static org.springframework.http.HttpStatus.NOT_ACCEPTABLE;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.NOT_IMPLEMENTED;
import static org.springframework.http.HttpStatus.PRECONDITION_FAILED;
import static org.springframework.http.HttpStatus.UNSUPPORTED_MEDIA_TYPE;
import static org.springframework.http.HttpStatus.SERVICE_UNAVAILABLE;
import static org.springframework.http.HttpStatus.TOO_MANY_REQUESTS;
import static org.springframework.http.HttpStatus.UNAUTHORIZED;
import static org.springframework.http.HttpStatus.UNPROCESSABLE_CONTENT;
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;

/**
Expand Down Expand Up @@ -98,8 +102,12 @@ static Stream<Arguments> errorCodes() {
args(METHOD_NOT_ALLOWED, HttpClientErrorException.MethodNotAllowed.class),
args(NOT_ACCEPTABLE, HttpClientErrorException.NotAcceptable.class),
args(CONFLICT, HttpClientErrorException.Conflict.class),
args(GONE, HttpClientErrorException.Gone.class),
args(PRECONDITION_FAILED, HttpClientErrorException.PreconditionFailed.class),
args(UNSUPPORTED_MEDIA_TYPE, HttpClientErrorException.UnsupportedMediaType.class),
args(TOO_MANY_REQUESTS, HttpClientErrorException.TooManyRequests.class),
args(UNPROCESSABLE_ENTITY, HttpClientErrorException.UnprocessableEntity.class),
args(UNPROCESSABLE_CONTENT, HttpClientErrorException.UnprocessableContent.class),
args(I_AM_A_TEAPOT, HttpClientErrorException.class),
// 5xx
args(INTERNAL_SERVER_ERROR, HttpServerErrorException.InternalServerError.class),
Expand Down