Package mg.emberframework.core.handler
Class ExceptionHandler
java.lang.Object
mg.emberframework.core.handler.ExceptionHandler
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 TypeMethodDescriptionstatic 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.
-
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 responsestatusCode
- the HTTP status codeexception
- 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 requestresponse
- the HTTP responsestatusCode
- the HTTP status codeexception
- the exception to processpage
- the custom error page URL- Throws:
jakarta.servlet.ServletException
- if a servlet error occurs during forwardingIOException
- 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 handlerequest
- the HTTP requestresponse
- 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 handlerequest
- the HTTP requestresponse
- the HTTP response- Throws:
jakarta.servlet.ServletException
- if a servlet error occurs
-