All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.rollbar.spring.webmvc.RollbarHandlerExceptionResolver Maven / Gradle / Ivy

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
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy