本文整理匯總了Java中javax.ws.rs.core.Response.Status.Family.CLIENT_ERROR屬性的典型用法代碼示例。如果您正苦於以下問題:Java Family.CLIENT_ERROR屬性的具體用法?Java Family.CLIENT_ERROR怎麽用?Java Family.CLIENT_ERROR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類javax.ws.rs.core.Response.Status.Family
的用法示例。
在下文中一共展示了Family.CLIENT_ERROR屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: toResponse
@Override
public Response toResponse(@NonNull Exception exception) {
ResponseBuilder builder;
StatusType statusInfo;
if (exception instanceof WebApplicationException) {
Response response = ((WebApplicationException) exception).getResponse();
builder = Response.fromResponse(response);
statusInfo = response.getStatusInfo();
} else {
builder = Response.serverError();
statusInfo = Status.INTERNAL_SERVER_ERROR;
}
SimpleExceptionJson simpleExceptionJson = new SimpleExceptionJson(statusInfo.getReasonPhrase(),
statusInfo.getStatusCode(), exception.getMessage());
builder.entity(simpleExceptionJson);
builder.type("application/problem+json");
if (statusInfo.getFamily() == Family.CLIENT_ERROR) {
log.debug("Got client Exception", exception);
} else {
log.error("Sending error to client", exception);
}
return builder.build();
}
示例2: convert
public <T> EndpointResponse<T> convert(Response response, EndpointRequest request) {
Family statusFamily = response.getStatusInfo().getFamily();
if (statusFamily == Family.SERVER_ERROR || statusFamily == Family.CLIENT_ERROR) {
return endpointResponseErrorFallback.onError(ErrorHttpResponseMessage.from(response, request), request.responseType());
} else {
return doConvert(response, request.responseType());
}
}
示例3: getFamily
public Family getFamily() {
return Family.CLIENT_ERROR;
}