本文整理匯總了Java中javax.ws.rs.WebApplicationException.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java WebApplicationException.getMessage方法的具體用法?Java WebApplicationException.getMessage怎麽用?Java WebApplicationException.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.ws.rs.WebApplicationException
的用法示例。
在下文中一共展示了WebApplicationException.getMessage方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convertExceptionToJsonResponse
import javax.ws.rs.WebApplicationException; //導入方法依賴的package包/類
public static ErrorResponse convertExceptionToJsonResponse(int status, WebApplicationException webAppException)
{
final ErrorResponse err = new ErrorResponse();
err.setCode(status);
String msg = webAppException.getMessage();
// if we happen to be using an 'unofficial' HTTP code, just repeat the
// exception message
String statusCodeErr = Status.fromStatusCode(status) != null ? Status.fromStatusCode(status).getReasonPhrase()
: msg;
err.setError(statusCodeErr);
if( webAppException.getCause() != null )
{
msg = webAppException.getCause().getMessage();
}
err.setErrorDescription(msg);
return err;
}
示例2: toResponse
import javax.ws.rs.WebApplicationException; //導入方法依賴的package包/類
@Override
public Response toResponse(WebApplicationException exception) {
log.error("Exception happened in RedirectorWebService", exception);
int exceptionStatusCode = exception.getResponse().getStatus();
String exceptionMessage = exception.getMessage();
if (exceptionMessage == null) {
Response.Status exceptionStatus = Response.Status.fromStatusCode(exceptionStatusCode);
exceptionMessage = (exceptionStatus != null)
? exceptionStatus.getReasonPhrase()
: String.format("Exception has been thrown with Status Code : %s", exceptionStatusCode);
}
return Response.status(exceptionStatusCode)
.entity(exceptionMessage)
.type(MediaType.TEXT_PLAIN)
.build();
}
示例3: getResult
import javax.ws.rs.WebApplicationException; //導入方法依賴的package包/類
public Result getResult(WebTarget target) {
WebTarget t = target;
target.path(Joiner.on(",").join(indexes)).path("_mapping");
if (indexes.size() > 0) {
t = t.path(Joiner.on(",").join(indexes));
}
t = t.path("_mapping");
if (types.size() > 0) {
t = t.path(Joiner.on(",").join(types));
}
try {
return new JsonResult(t.request().buildGet().invoke(byte[].class));
} catch (WebApplicationException e) {
return new FailureResult(e.getResponse().getStatus(), e.getMessage());
}
}
示例4: toResponse
import javax.ws.rs.WebApplicationException; //導入方法依賴的package包/類
@Override
public Response toResponse(final Exception exception) {
final WebApplicationException webAppException = ExceptionUtils.toWebAppException(exception);
String message = webAppException.getMessage();
if (message != null && message.startsWith("HTTP ")) {
message = message.substring(5);
}
final int status = webAppException.getResponse().getStatus();
final View view = new View("error");
view.getModel().put("message", message);
return Response.status(status).type(MediaType.TEXT_HTML_TYPE).entity(view).build();
}
示例5: getResult
import javax.ws.rs.WebApplicationException; //導入方法依賴的package包/類
@Override
public Result getResult(WebTarget target) {
try {
return new JsonResult(target.path("_nodes").request().header(CONTENT_TYPE, APPLICATION_JSON).buildGet().invoke(byte[].class));
} catch (WebApplicationException e) {
return new FailureResult(e.getResponse().getStatus(), e.getMessage());
}
}
示例6: MinijaxJsonExceptionWrapper
import javax.ws.rs.WebApplicationException; //導入方法依賴的package包/類
public MinijaxJsonExceptionWrapper(final WebApplicationException ex) {
this(ex.getResponse().getStatus(), ex.getMessage());
}