将Rollbar与Spring Goot / jHipster集成的最佳方法?

时间:2019-07-10 09:16:47

标签: spring-boot jhipster rollbar

我正在尝试将https://rollbar.com/集成到Jhipster应用程序中。

在他们的documentation中,他们建议创建一个如下所示的类:

@ControllerAdvice
@EnableWebMvc
public class GlobalExceptionHandlerController {

    public static final String DEFAULT_ERROR_VIEW = "error";

    @ExceptionHandler(value = Exception.class)
    public ModelAndView defaultErrorHandler(HttpServletRequest req, Exception e) throws Exception {

        final Rollbar rollbar = new Rollbar(withAccessToken("8e194f5f31db4ff1b4e3e0951a40c936")
                .environment("production").handleUncaughtErrors(true).build());
        rollbar.error(e);
        ModelAndView mav = new ModelAndView();
        mav.addObject("exception", e);
        mav.addObject("url", req.getRequestURL());
        mav.setViewName(DEFAULT_ERROR_VIEW);
        return mav;
    }

但是,jHipster已经有一个用@ControllerAdvice注释的类:public class ExceptionTranslator implements ProblemHandling,如果我添加了上述方法,rollbar集成就可以了,但是随后

的测试失败了
ExceptionTranslatorIntTest.testExceptionWithResponseStatus:126 Status expected:<400> but was:<200>
  ExceptionTranslatorIntTest.testInternalServerError:135 Status expected:<500> but was:<200>

由于新方法禁止输入ExceptionTranslator.process(@Nullable ResponseEntity<Problem> entity)方法。

我不确定要实现这两个功能的好方法是什么?

谢谢!

0 个答案:

没有答案
相关问题