本文整理匯總了Java中org.springframework.web.client.HttpClientErrorException.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpClientErrorException.getMessage方法的具體用法?Java HttpClientErrorException.getMessage怎麽用?Java HttpClientErrorException.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.web.client.HttpClientErrorException
的用法示例。
在下文中一共展示了HttpClientErrorException.getMessage方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import org.springframework.web.client.HttpClientErrorException; //導入方法依賴的package包/類
@Override
protected RestResponsePage<Approval> run() throws Exception {
try {
ParameterizedTypeReference<RestResponsePage<Approval>>
responsetype =
new ParameterizedTypeReference<RestResponsePage<Approval>>() {
};
ResponseEntity<RestResponsePage<Approval>>
result =
restTemplate
.exchange(uriBuilder.build().encode().toUri(), HttpMethod.POST,
new HttpEntity<>(approvalFilters), responsetype);
return result.getBody();
} catch (HttpClientErrorException exception) {
throw new HystrixBadRequestException(exception.getMessage(),
new HttpBadRequestException(ErrorResponse.getErrorResponse(exception), exception));
}
}
示例2: toResponse
import org.springframework.web.client.HttpClientErrorException; //導入方法依賴的package包/類
@Override
public Response toResponse(HttpClientErrorException exception) {
RestError error = new RestError(
exception.getMessage(),
exception.getMessage(),
ErrorMap.from(new String(exception.getResponseBodyAsByteArray(), StandardCharsets.UTF_8)),
exception.getStatusCode().value());
return Response.status(exception.getStatusCode().value()).type(MediaType.APPLICATION_JSON_TYPE).entity(error).build();
}
示例3: run
import org.springframework.web.client.HttpClientErrorException; //導入方法依賴的package包/類
@Override
protected LocationResponseModel run() throws Exception {
URI url = JerseyUriBuilder.fromUri(LocationConstants.URL).build();
HttpEntity<LocationRequestModel> request = new HttpEntity<LocationRequestModel>(model, headers);
try {
ResponseEntity<LocationResponseModel>
entity =
restClient.postForEntity(url, request, LocationResponseModel.class);
return entity.getBody();
} catch (HttpClientErrorException exception) {
throw new HystrixBadRequestException(exception.getMessage(),
new HttpBadRequestException(ErrorResponse.getErrorResponse(exception), exception));
}
}
示例4: run
import org.springframework.web.client.HttpClientErrorException; //導入方法依賴的package包/類
@Override
protected CreateApprovalResponse run() throws Exception {
URI link = JerseyUriBuilder.fromUri(url).build();
try {
ResponseEntity<CreateApprovalResponse>
entity =
restTemplate.postForEntity(link, request, CreateApprovalResponse.class);
return entity.getBody();
} catch (HttpClientErrorException exception) {
throw new HystrixBadRequestException(exception.getMessage(),
new HttpBadRequestException(ErrorResponse.getErrorResponse(exception), exception));
}
}
示例5: run
import org.springframework.web.client.HttpClientErrorException; //導入方法依賴的package包/類
@Override
protected CreateApprovalResponse run() throws Exception {
try {
return restTemplate.getForEntity(path, CreateApprovalResponse.class, approvalId).getBody();
} catch (HttpClientErrorException exception) {
throw new HystrixBadRequestException(exception.getMessage(),
new HttpBadRequestException(ErrorResponse.getErrorResponse(exception), exception));
}
}
示例6: run
import org.springframework.web.client.HttpClientErrorException; //導入方法依賴的package包/類
@Override
protected String run() throws Exception {
try {
restTemplate.put(path, request, approvalId);
return approvalId;
} catch (HttpClientErrorException exception) {
throw new HystrixBadRequestException(exception.getMessage(),
new HttpBadRequestException(ErrorResponse.getErrorResponse(exception), exception));
}
}
示例7: httpClientErrorException
import org.springframework.web.client.HttpClientErrorException; //導入方法依賴的package包/類
@ExceptionHandler(value = HttpClientErrorException.class)
public ResponseEntity<Object> httpClientErrorException(HttpClientErrorException exception) {
logger.error(exception.getMessage(), exception);
return new ResponseEntity<>(exception.getMessage(), new HttpHeaders(),
HttpStatus.valueOf(exception.getRawStatusCode()));
}
示例8: Request
import org.springframework.web.client.HttpClientErrorException; //導入方法依賴的package包/類
@ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "Bad Request (most likely the token is invalid)")
@ExceptionHandler(HttpClientErrorException.class)
public String handleHttpClientErrorException(HttpClientErrorException e) {
return e.getMessage();
}