当前位置: 首页>>代码示例>>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;未经允许,请勿转载。