本文整理匯總了Java中javax.ws.rs.ClientErrorException.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java ClientErrorException.getMessage方法的具體用法?Java ClientErrorException.getMessage怎麽用?Java ClientErrorException.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.ws.rs.ClientErrorException
的用法示例。
在下文中一共展示了ClientErrorException.getMessage方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: toResponse
import javax.ws.rs.ClientErrorException; //導入方法依賴的package包/類
@Override
public Response toResponse(final ClientErrorException exception) {
final Response response = exception.getResponse();
final RestError error = new RestError(exception.getMessage(), "Given request is not acceptable", null,
response.getStatus());
return Response.fromResponse(response).type(MediaType.APPLICATION_JSON_TYPE).entity(error).build();
}
示例2: executeRequest
import javax.ws.rs.ClientErrorException; //導入方法依賴的package包/類
/**
* Execute a request for the given method using the given builder.
* @param httpMethod The HTTP method to be used, as specified by one of the constants
* in {@link HttpMethod}
* @param builder The builder used to execute the request. Usually this builder is created
* using {@link #getBaseResource()}.path(...).entity(...).accept(...)...
* @param returnType The return type for the data returned by the request.
* @return The result of executing the HTTP request.
*/
public <T> T executeRequest(String httpMethod, Builder builder, Entity<?> entity, Class<T> returnType) {
Response response = null;
try {
initializeConnection(httpMethod);
builder = updateBuilder(builder);
response = builder.build(httpMethod, entity).invoke();
return checkResponseAndGetOutput(httpMethod, builder, response, returnType);
} catch ( ClientErrorException e ) {
throw new RuntimeException("Error accessing remote system:\n"+e.getMessage(), e);
} finally {
if ( response != null ) { response.close(); }
}
}
示例3: PulsarAdminException
import javax.ws.rs.ClientErrorException; //導入方法依賴的package包/類
public PulsarAdminException(ClientErrorException e) {
super(getReasonFromServer(e), e);
this.httpError = e.getMessage();
this.statusCode = e.getResponse().getStatus();
}