Class ExceptionHandler

java.lang.Object
mg.emberframework.core.handler.ExceptionHandler

public class ExceptionHandler extends Object
Handles exceptions and generates error responses in the Ember Framework.

This utility class provides methods to process exceptions, either by rendering a default HTML error page or forwarding to a custom error page.

Since:
1.0.0
Version:
1.0.0
Author:
Sandratra NIAINA
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    handleException(Exception e, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
    Handles a single exception and generates an appropriate response.
    static void
    handleExceptions(List<Exception> exceptions, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
    Handles a list of exceptions and processes each one.
    static void
    processCustomError(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, int statusCode, Exception exception, String page)
    Processes an error by forwarding to a custom error page.
    static void
    processError(jakarta.servlet.http.HttpServletResponse response, int statusCode, Exception exception)
    Processes an error by generating a default HTML error page.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • processError

      public static void processError(jakarta.servlet.http.HttpServletResponse response, int statusCode, Exception exception) throws IOException
      Processes an error by generating a default HTML error page.
      Parameters:
      response - the HTTP response
      statusCode - the HTTP status code
      exception - the exception to process
      Throws:
      IOException - if an I/O error occurs while writing the response
    • processCustomError

      public static void processCustomError(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, int statusCode, Exception exception, String page) throws jakarta.servlet.ServletException, IOException
      Processes an error by forwarding to a custom error page.
      Parameters:
      request - the HTTP request
      response - the HTTP response
      statusCode - the HTTP status code
      exception - the exception to process
      page - the custom error page URL
      Throws:
      jakarta.servlet.ServletException - if a servlet error occurs during forwarding
      IOException - if an I/O error occurs
    • handleException

      public static void handleException(Exception e, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException
      Handles a single exception and generates an appropriate response.
      Parameters:
      e - the exception to handle
      request - the HTTP request
      response - the HTTP response
      Throws:
      jakarta.servlet.ServletException - if a servlet error occurs
    • handleExceptions

      public static void handleExceptions(List<Exception> exceptions, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException
      Handles a list of exceptions and processes each one.
      Parameters:
      exceptions - the list of exceptions to handle
      request - the HTTP request
      response - the HTTP response
      Throws:
      jakarta.servlet.ServletException - if a servlet error occurs