本文整理汇总了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();
}