java类org.springframework.web.bind.annotation.ResponseStatus的实例源码

ErrorController.java 文件源码 项目:Spring-Security-Third-Edition 阅读 20 收藏 0 点赞 0 评论 0
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
ExceptionTranslator.java 文件源码 项目:klask-io 阅读 31 收藏 0 点赞 0 评论 0
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorDTO> processRuntimeException(Exception ex) throws Exception {
    BodyBuilder builder;
    ErrorDTO errorDTO;
    ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class);
    if (responseStatus != null) {
        builder = ResponseEntity.status(responseStatus.value());
        errorDTO = new ErrorDTO("error." + responseStatus.value().value(), responseStatus.reason());
    } else {
        builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR);
        errorDTO = new ErrorDTO(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error");
    }
    log.error("Exception in rest call", ex);
    errorDTO.add("error", "error", ex.getMessage());
    return builder.body(errorDTO);
}
ErrorController.java 文件源码 项目:Spring-Security-Third-Edition 阅读 22 收藏 0 点赞 0 评论 0
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!   ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append(" root cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
ErrorController.java 文件源码 项目:Spring-Security-Third-Edition 阅读 24 收藏 0 点赞 0 评论 0
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
ErrorController.java 文件源码 项目:Spring-Security-Third-Edition 阅读 29 收藏 0 点赞 0 评论 0
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
FormModelCollectionResource.java 文件源码 项目:plumdo-work 阅读 22 收藏 0 点赞 0 评论 0
@ApiOperation(value = "分页查询表单模型", notes = "根据传进来的查询参数,获取表单模型信息")
@ApiImplicitParams({ 
    @ApiImplicitParam(name = "id", value = "主键ID", required = false, dataType = "int", paramType = "query"), 
    @ApiImplicitParam(name = "category", value = "模型分类,模糊匹配", required = false, dataType = "string", paramType = "query"), 
    @ApiImplicitParam(name = "key", value = "模型键,模糊匹配", required = false, dataType = "string", paramType = "query"), 
    @ApiImplicitParam(name = "name", value = "模型名称,模糊匹配", required = false, dataType = "string", paramType = "query"), 
    @ApiImplicitParam(name = "tenantId", value = "租户ID,模糊匹配", required = false, dataType = "string", paramType = "query"), 
    @ApiImplicitParam(name = "pageNum", value = "分页查询开始查询的页码", defaultValue = "1", required = false, dataType = "int", paramType = "query"),
    @ApiImplicitParam(name = "pageSize", value = "分页查询每页显示的记录数", defaultValue = "10", required = false, dataType = "int", paramType = "query"), 
    @ApiImplicitParam(name = "sortName", value = "排序的字段,可以多值以逗号分割", required = false, dataType = "string", paramType = "query"), 
    @ApiImplicitParam(name = "sortOrder", value = "排序的方式,可以为asc或desc,可以多值以逗号分割", required = false, dataType = "string", paramType = "query") 
})
@RequestMapping(value = "/form-models", method = RequestMethod.GET, produces = "application/json")
@ResponseStatus(value = HttpStatus.OK)
public PageResponse<FormModelResponse> getFormModels(@ApiIgnore @RequestParam Map<String, String> requestParams) {
    Criteria<FormModel> criteria = new Criteria<FormModel>();
    criteria.add(Restrictions.eq("id", requestParams.get("id"), true));
    criteria.add(Restrictions.like("category", requestParams.get("category"), true));
    criteria.add(Restrictions.like("key", requestParams.get("key"), true));
    criteria.add(Restrictions.like("name", requestParams.get("name"), true));
    criteria.add(Restrictions.like("tenantId", requestParams.get("tenantId"), true));
    return responseFactory.createFormModelPageResponse(formModelRepository.findAll(criteria, getPageable(requestParams)));
}
ErrorController.java 文件源码 项目:Spring-Security-Third-Edition 阅读 34 收藏 0 点赞 0 评论 0
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
ErrorController.java 文件源码 项目:Spring-Security-Third-Edition 阅读 23 收藏 0 点赞 0 评论 0
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
RolesEndpoint.java 文件源码 项目:tokamak 阅读 20 收藏 0 点赞 0 评论 0
@Authorize(scopes = "roles:create")
@ResponseStatus(value = HttpStatus.CREATED)
@RequestMapping(value = "/v1/roles", method = POST, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE)
public RoleRepresentation create(@RequestBody RoleRepresentation representation) {
    Role role = roleConversionService.convert(representation);
    Role created = roleService.create(role).orThrow();
    return roleConversionService.convert(roleService.findById(created.getId()).orThrow());
}
ErrorController.java 文件源码 项目:Spring-Security-Third-Edition 阅读 24 收藏 0 点赞 0 评论 0
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    sb.append(", root cause: ").append((throwable != null && throwable.getCause() != null ? throwable.getCause() : "Unknown cause"));
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
ErrorController.java 文件源码 项目:Spring-Security-Third-Edition 阅读 27 收藏 0 点赞 0 评论 0
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!   ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append(" root cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
UnilogResource.java 文件源码 项目:Blockchain-Academic-Verification-Service 阅读 22 收藏 0 点赞 0 评论 0
@PostMapping(value = "/complete/registration", headers = "Accept=application/json", params = "action=Submit")
@ResponseStatus(value = HttpStatus.ACCEPTED)
public String completeRegistration(@ModelAttribute final RegistrationRequest request, final Map<String, Object> model)
        throws UserExistsException, IOException, InterruptedException {
    LOGGER.info("Completing registration for transcript owner");
    if (userService.isRegistered(request.getRecipientEmailAddress())) {
        model.put("alreadyRegistered", true);
    } else if (userService.completeRegistration(request)) {
        LOGGER.info("Adding qualifications");
        model.put("success", true);
        RegistrationRequest registrationRequest = new RegistrationRequest();
        model.put("registrationRequest", registrationRequest);
    } else {
        model.put("error", true);
    }
    return "registration";
}
AuthController.java 文件源码 项目:iotplatform 阅读 22 收藏 0 点赞 0 评论 0
@PreAuthorize("isAuthenticated()")
@RequestMapping(value = "/auth/changePassword", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
public void changePassword (
        @RequestParam(value = "currentPassword") String currentPassword,
        @RequestParam(value = "newPassword") String newPassword) throws IoTPException {
    try {
        SecurityUser securityUser = getCurrentUser();
        UserCredentials userCredentials = userService.findUserCredentialsByUserId(securityUser.getId());
        if (!passwordEncoder.matches(currentPassword, userCredentials.getPassword())) {
            throw new IoTPException("Current password doesn't match!", IoTPErrorCode.BAD_REQUEST_PARAMS);
        }
        userCredentials.setPassword(passwordEncoder.encode(newPassword));
        userService.saveUserCredentials(userCredentials);
    } catch (Exception e) {
        throw handleException(e);
    }
}
ErrorController.java 文件源码 项目:Spring-Security-Third-Edition 阅读 22 收藏 0 点赞 0 评论 0
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!   ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append(" root cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
ProcessDefinitionActivateResource.java 文件源码 项目:plumdo-work 阅读 20 收藏 0 点赞 0 评论 0
@RequestMapping(value = "/process-definition/{processDefinitionId}/activate", method = RequestMethod.PUT, produces = "application/json", name = "流程定义激活")
@ResponseStatus(value = HttpStatus.OK)
public void activateProcessDefinition(@PathVariable String processDefinitionId,@RequestBody(required=false) ProcessDefinitionActionRequest actionRequest) {

    ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);

    if (!processDefinition.isSuspended()) {
        throw new FlowableConflictException("Process definition with id '" + processDefinition.getId() + " ' is already active");
    }

    if (actionRequest == null) {
        repositoryService.activateProcessDefinitionById(processDefinitionId);
    }else{
        repositoryService.activateProcessDefinitionById(processDefinition.getId(), actionRequest.isIncludeProcessInstances(),actionRequest.getDate());
    }
}
PluginController.java 文件源码 项目:iotplatform 阅读 23 收藏 0 点赞 0 评论 0
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
@RequestMapping(value = "/plugin/{pluginId}", method = RequestMethod.DELETE)
@ResponseStatus(value = HttpStatus.OK)
public void deletePlugin(@PathVariable("pluginId") String strPluginId) throws IoTPException {
    checkParameter("pluginId", strPluginId);
    try {
        PluginId pluginId = new PluginId(toUUID(strPluginId));
        PluginMetaData plugin = checkPlugin(pluginService.findPluginById(pluginId));
        pluginService.deletePluginById(pluginId);
        //actorService.onPluginStateChange(plugin.getTenantId(), plugin.getId(), ComponentLifecycleEvent.DELETED);
        JsonObject json = new JsonObject();
        json.addProperty(ThingsMetaKafkaTopics.TENANT_ID, plugin.getTenantId().toString());
        json.addProperty(ThingsMetaKafkaTopics.PLUGIN_ID, plugin.getId().toString());
        json.addProperty(ThingsMetaKafkaTopics.EVENT, ComponentLifecycleEvent.DELETED.name());
        msgProducer.send(ThingsMetaKafkaTopics.METADATA_PLUGIN_TOPIC, plugin.getId().toString(), json.toString());
    } catch (Exception e) {
        throw handleException(e);
    }
}
ErrorController.java 文件源码 项目:Spring-Security-Third-Edition 阅读 27 收藏 0 点赞 0 评论 0
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
ErrorController.java 文件源码 项目:Spring-Security-Third-Edition 阅读 23 收藏 0 点赞 0 评论 0
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    sb.append(", root cause: ").append((throwable != null && throwable.getCause() != null ? throwable.getCause() : "Unknown cause"));
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
EntityRelationController.java 文件源码 项目:iotplatform 阅读 27 收藏 0 点赞 0 评论 0
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
@RequestMapping(value = "/relation", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
public void saveRelation(@RequestBody EntityRelation relation) throws IoTPException {
  try {
    checkNotNull(relation);
    checkEntityId(relation.getFrom());
    checkEntityId(relation.getTo());
    if (relation.getTypeGroup() == null) {
      relation.setTypeGroup(RelationTypeGroup.COMMON);
    }
    relationService.saveRelation(relation).get();
  } catch (Exception e) {
    throw handleException(e);
  }
}
LocAdviceErrorAutoConfiguration.java 文件源码 项目:loc-framework 阅读 17 收藏 0 点赞 0 评论 0
@ResponseStatus(value = HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
//对于接口方法不匹配的异常处理
public BasicResult handleHttpRequestMethodNotSupportedException(
    HttpRequestMethodNotSupportedException e) {
  logError("httpRequestMethodNotSupportedException", e.getMessage(), e);
  return BasicResult
      .fail(BasicResultCode.METHOD_NOT_ALLOW_ERROR.getCode(),
          BasicResultCode.METHOD_NOT_ALLOW_ERROR.getMsg(),
          e.getMessage());
}
ErrorController.java 文件源码 项目:Spring-Security-Third-Edition 阅读 22 收藏 0 点赞 0 评论 0
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
ExceptionHandlers.java 文件源码 项目:spring-boot-aop 阅读 22 收藏 0 点赞 0 评论 0
@ExceptionHandler(ServletRequestBindingException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public ErrorResponse handle(final ServletRequestBindingException ex) {
    log.error("Missing parameter", ex);
    return new ErrorResponse("MISSING_PARAMETER", ex.getMessage());
}
TaskReturnResource.java 文件源码 项目:plumdo-work 阅读 17 收藏 0 点赞 0 评论 0
@RequestMapping(value="/task/{taskId}/return", method = RequestMethod.PUT, name="任务回退")
@ResponseStatus(value = HttpStatus.OK)
@Transactional(propagation = Propagation.REQUIRED)
public List<TaskResponse> returnTask(@PathVariable("taskId") String taskId,@RequestBody(required=false) TaskActionRequest actionRequest) {
    List<TaskResponse> responses = new ArrayList<TaskResponse>();

    Task task = getTaskFromRequest(taskId);

    if(task.getAssignee()==null){
        taskService.setAssignee(taskId, Authentication.getAuthenticatedUserId());
    }

   /* List<Task> tasks = taskExtService.returnTask(task.getId());
    for(Task nextTask : tasks){
        TaskExt taskExt = taskExtService.getTaskExtById(nextTask.getId());
        responses.add(restResponseFactory.createTaskResponse(taskExt));
    }*/
    return responses;
}
UserController.java 文件源码 项目:iotplatform 阅读 28 收藏 0 点赞 0 评论 0
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
@RequestMapping(value = "/user/sendActivationMail", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
public void sendActivationEmail(
        @RequestParam(value = "email") String email,
        HttpServletRequest request) throws IoTPException {
    try {
        User user = checkNotNull(userService.findUserByEmail(email));
        UserCredentials userCredentials = userService.findUserCredentialsByUserId(user.getId());
        if (!userCredentials.isEnabled()) {
            String baseUrl = constructBaseUrl(request);
            String activateUrl = String.format("%s/api/noauth/activate?activateToken=%s", baseUrl,
                    userCredentials.getActivateToken());
            mailService.sendActivationEmail(activateUrl, email);
        } else {
            throw new IoTPException("User is already active!", IoTPErrorCode.BAD_REQUEST_PARAMS);
        }
    } catch (Exception e) {
        throw handleException(e);
    }
}
AppRegistryController.java 文件源码 项目:spring-cloud-dashboard 阅读 19 收藏 0 点赞 0 评论 0
/**
 * Retrieve detailed information about a particular application.
 * @param type application type
 * @param name application name
 * @return detailed application information
 */
@RequestMapping(value = "/{type}/{name}", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public DetailedAppRegistrationResource info(
        @PathVariable("type") String type,
        @PathVariable("name") String name) {
    AppRegistration registration = appRegistry.find(name, type);
    if (registration == null) {
        throw new NoSuchAppRegistrationException(name, type);
    }
    DetailedAppRegistrationResource result = new DetailedAppRegistrationResource(assembler.toResource(registration));
    Resource resource = registration.getResource();

    List<ConfigurationMetadataProperty> properties = metadataResolver.listProperties(resource);
    for (ConfigurationMetadataProperty property : properties) {
        result.addOption(property);
    }
    return result;
}
ErrorController.java 文件源码 项目:Spring-Security-Third-Edition 阅读 29 收藏 0 点赞 0 评论 0
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
ErrorController.java 文件源码 项目:Spring-Security-Third-Edition 阅读 24 收藏 0 点赞 0 评论 0
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
ExceptionHandlers.java 文件源码 项目:spring-boot-aop 阅读 27 收藏 0 点赞 0 评论 0
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(Throwable.class)
@ResponseBody
public ErrorResponse handle(final Throwable ex) {
    log.error("Unexpected error", ex);
    return new ErrorResponse("INTERNAL_SERVER_ERROR", "An unexpected internal server error occured");
}
ErrorController.java 文件源码 项目:Spring-Security-Third-Edition 阅读 23 收藏 0 点赞 0 评论 0
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!   ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append(" root cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
GlobalExceptionHandler.java 文件源码 项目:plumdo-work 阅读 28 收藏 0 点赞 0 评论 0
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(ObjectNotFoundException.class)
@ResponseBody
public ErrorInfo handleNotFound(ObjectNotFoundException e) {
    LOGGER.error("not found object", e);
    return new ErrorInfo("not found object", e);
}


问题


面经


文章

微信
公众号

扫码关注公众号