當前位置: 首頁>>代碼示例>>Java>>正文


Java ExceptionMapper.toResponse方法代碼示例

本文整理匯總了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();
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:21,代碼來源:MinijaxApplication.java

示例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);
    }
}
 
開發者ID:codebulb,項目名稱:crudlet,代碼行數:23,代碼來源:RestfulExceptionMapper.java

示例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());
   }
}
 
開發者ID:resteasy,項目名稱:resteasy-examples,代碼行數:18,代碼來源:EJBExceptionMapper.java

示例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());
        }
    }
}
 
開發者ID:projectomakase,項目名稱:omakase,代碼行數:18,代碼來源:EJBExceptionMapper.java

示例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());
    }
}
 
開發者ID:bazaarvoice,項目名稱:emodb,代碼行數:13,代碼來源:UncheckedExecutionExceptionMapper.java

示例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);
}
 
開發者ID:apache,項目名稱:tomee,代碼行數:16,代碼來源:EJBExceptionMapper.java

示例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();
}
 
開發者ID:fcrepo4,項目名稱:fcrepo4,代碼行數:14,代碼來源:RepositoryRuntimeExceptionMapper.java

示例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);
}
 
開發者ID:redbooth,項目名稱:baseline,代碼行數:7,代碼來源:DBIExceptionMapper.java


注:本文中的javax.ws.rs.ext.ExceptionMapper.toResponse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。