com.rollbar.spring.webmvc.RollbarHandlerExceptionResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rollbar-spring6-webmvc Show documentation
Show all versions of rollbar-spring6-webmvc Show documentation
For connecting your applications built on the JVM to Rollbar for Error Reporting
The newest version!
package com.rollbar.spring.webmvc;
import com.rollbar.notifier.Rollbar;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;
@Order(Ordered.HIGHEST_PRECEDENCE)
@ControllerAdvice
public class RollbarHandlerExceptionResolver implements HandlerExceptionResolver {
private Rollbar rollbar;
@Autowired
public RollbarHandlerExceptionResolver(Rollbar rollbar) {
this.rollbar = rollbar;
}
@Override
public ModelAndView resolveException(HttpServletRequest request,
HttpServletResponse response,
Object handler,
Exception ex) {
rollbar.error(ex);
return null; // returning null forces other resolvers to handle the exception
}
}