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