### Question:
ApiExceptionHandler { @ExceptionHandler(Exception.class) public Result exceptionHandler(Exception e, HandlerMethod hm) { ApiException ce = hm.getMethodAnnotation(ApiException.class); if (ce == null) { logger.error(e.getMessage(), e); return Result.errorWithArgs(Status.INTERNAL_SERVER_ERROR_ARGS, e.getMessage()); } Status st = ce.value(); logger.error(st.getMsg(), e); return Result.error(st); }  @ExceptionHandler(Exception.class) Result exceptionHandler(Exception e, HandlerMethod hm);  }### Answer:
@Test public void exceptionHandler() throws NoSuchMethodException { ApiExceptionHandler handler = new ApiExceptionHandler(); AccessTokenController controller = new AccessTokenController(); Method method = controller.getClass().getMethod("createToken", User.class, int.class, String.class, String.class); HandlerMethod hm = new HandlerMethod(controller, method); Result result = handler.exceptionHandler(new RuntimeException("test exception"), hm); Assert.assertEquals(Status.CREATE_ACCESS_TOKEN_ERROR.getCode(),result.getCode().intValue()); }
@Test public void exceptionHandlerRuntime() throws NoSuchMethodException { ApiExceptionHandler handler = new ApiExceptionHandler(); ProcessDefinitionController controller = new ProcessDefinitionController(); Method method = controller.getClass().getMethod("batchExportProcessDefinitionByIds", User.class, String.class, String.class, HttpServletResponse.class); HandlerMethod hm = new HandlerMethod(controller, method); Result result = handler.exceptionHandler(new RuntimeException("test exception"), hm); Assert.assertEquals(Status.INTERNAL_SERVER_ERROR_ARGS.getCode(),result.getCode().intValue()); }