Class YupErrorController

java.lang.Object
app.YUP.controller.YupErrorController
All Implemented Interfaces:
org.springframework.boot.web.servlet.error.ErrorController

@Controller public class YupErrorController extends Object implements org.springframework.boot.web.servlet.error.ErrorController
This class is a controller for handling errors in the application. It implements the ErrorController interface provided by Spring Boot.
  • Constructor Details

    • YupErrorController

      public YupErrorController()
  • Method Details

    • handleError

      @RequestMapping("/error") public String handleError(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model)
      This method is used to handle errors in the application. It takes a HttpServletRequest object, a HttpServletResponse object, and a Model object as parameters. It sets the HTTP status code of the response to 403 (Forbidden). It adds an attribute to the model with the error message from the request. It returns a string that represents the name of the view to be rendered.
      Parameters:
      request - This is the HttpServletRequest object that contains the request details.
      response - This is the HttpServletResponse object that contains the response details.
      model - This is the Model object that can be used to pass attributes to the view.
      Returns:
      String This returns the name of the view to be rendered.
    • sendErrorEmail

      @PostMapping("/sendErrorEmail") @ResponseBody public void sendErrorEmail(@RequestBody Map<String,String> payload, jakarta.servlet.http.HttpServletResponse response)
      This method is used to send an error email to the team. It takes a Map object containing the error message as a parameter. It sets the HTTP status code of the response to 200 (OK). It creates an EmailDetails object with the recipient's email address, the error message, a subject line, and an empty attachment. It then calls the sendMailWithoutAttachment method of the EmailService class to send the email.
      Parameters:
      payload - This is a Map object containing the error message.
      response - This is the HttpServletResponse object that contains the response details.