本文整理匯總了Java中javax.ws.rs.ext.ExceptionMapper.toResponse方法的典型用法代碼示例。如果您正苦於以下問題:Java ExceptionMapper.toResponse方法的具體用法?Java ExceptionMapper.toResponse怎麽用?Java ExceptionMapper.toResponse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.ws.rs.ext.ExceptionMapper
的用法示例。
在下文中一共展示了ExceptionMapper.toResponse方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: toResponse
import javax.ws.rs.ext.ExceptionMapper; //導入方法依賴的package包/類
@SuppressWarnings({ "unchecked", "rawtypes" })
private Response toResponse(final MinijaxRequestContext context, final Exception ex) {
final MinijaxResourceMethod rm = context.getResourceMethod();
final List<MediaType> mediaTypes;
if (rm != null) {
mediaTypes = rm.getProduces();
} else {
mediaTypes = context.getAcceptableMediaTypes();
}
for (final MediaType mediaType : mediaTypes) {
final ExceptionMapper mapper = providers.getExceptionMapper(ex.getClass(), mediaType);
if (mapper != null) {
return mapper.toResponse(ex);
}
}
return ExceptionUtils.toWebAppException(ex).getResponse();
}
示例2: toResponse
import javax.ws.rs.ext.ExceptionMapper; //導入方法依賴的package包/類
@Override
public Response toResponse(Exception ex) {
if (Options.RETURN_EXCEPTION_BODY) {
if (ex instanceof PersistenceException) {
Throwable cause = ex.getCause();
if (cause != null) { // The type of this exception is determined at runtime
cause = cause.getCause();
if (cause instanceof SQLIntegrityConstraintViolationException) {
return new RestErrorBuilder(cause).createResponse();
}
}
}
}
ExceptionMapper exceptionMapper = providers.getExceptionMapper(ex.getClass());
if (exceptionMapper == null || exceptionMapper == this) {
return Response.serverError().build();
}
else {
return exceptionMapper.toResponse(ex);
}
}
示例3: toResponse
import javax.ws.rs.ext.ExceptionMapper; //導入方法依賴的package包/類
public Response toResponse(EJBException exception)
{
if (exception.getCausedByException() == null)
{
return Response.serverError().build();
}
Class cause = exception.getCausedByException().getClass();
ExceptionMapper mapper = providers.getExceptionMapper(cause);
if (mapper == null)
{
return Response.serverError().build();
}
else
{
return mapper.toResponse(exception.getCausedByException());
}
}
示例4: toResponse
import javax.ws.rs.ext.ExceptionMapper; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public Response toResponse(EJBException exception) {
if (exception.getCausedByException() == null) {
LOGGER.error(exception.getMessage(), exception);
return Responses.errorResponse(Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(), "Internal Server Error", exception, LOGGER.isInfoEnabled());
} else {
Class cause = exception.getCausedByException().getClass();
ExceptionMapper mapper = providers.getExceptionMapper(cause);
if (mapper == null) {
LOGGER.error(exception.getMessage(), exception);
return Responses.errorResponse(Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(), "Internal Server Error", exception, LOGGER.isInfoEnabled());
} else {
return mapper.toResponse(exception.getCausedByException());
}
}
}
示例5: toResponse
import javax.ws.rs.ext.ExceptionMapper; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public Response toResponse(UncheckedExecutionException e) {
ExceptionMapper mapper = _providers.getExceptionMapper(e.getCause().getClass());
if (mapper == null) {
return null;
} else if (mapper instanceof LoggingExceptionMapper) {
return mapper.toResponse(e);
} else {
return mapper.toResponse(e.getCause());
}
}
示例6: toResponse
import javax.ws.rs.ext.ExceptionMapper; //導入方法依賴的package包/類
@Override
public Response toResponse(final EJBException ejbException) {
final Exception cause = ejbException.getCausedByException();
if (cause != null) {
final Class causeClass = cause.getClass();
final ExceptionMapper exceptionMapper = providers.getExceptionMapper(causeClass);
if (exceptionMapper == null) {
return defaultResponse(cause);
}
return exceptionMapper.toResponse(cause);
} else if (EJBAccessException.class.isInstance(ejbException)) {
return Response.status(Response.Status.FORBIDDEN).build();
}
return defaultResponse(ejbException);
}
示例7: toResponse
import javax.ws.rs.ext.ExceptionMapper; //導入方法依賴的package包/類
@Override
public Response toResponse(final RepositoryRuntimeException e) {
final Throwable cause = e.getCause();
@SuppressWarnings("unchecked")
final ExceptionMapper<Throwable> exceptionMapper =
(ExceptionMapper<Throwable>) providers.getExceptionMapper(cause.getClass());
if (exceptionMapper != null) {
return exceptionMapper.toResponse(cause);
}
LOGGER.error("Caught a repository exception: {}", e.getMessage());
debugException(this, cause, LOGGER);
return serverError().entity(getStackTraceAsString(e)).type(TEXT_PLAIN_WITH_CHARSET).build();
}
示例8: toResponse
import javax.ws.rs.ext.ExceptionMapper; //導入方法依賴的package包/類
@Override
public Response toResponse(DBIException throwable) {
Throwable cause = Databases.findExceptionRootCause(throwable);
ExceptionMapper actualMapper = providers.getExceptionMapper(cause.getClass());
return actualMapper.toResponse(cause);
}