package org.articles.controller.page;

import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;

/**
 *  Application errors controller
 *  @author Andrey Yurzanov
 */
@Controller("app-error-controller")
public class ApplicationErrorController implements ErrorController {
  /**
   *  For errors handling
   *  @return Main page url
   */
  @GetMapping("/error")
  @ExceptionHandler(Exception.class)
  public String error() {
    return "redirect:/";
  }
  @Override
  public String getErrorPath() {
    return "/error";
  }
}
