diff --git a/src/org/kar/archidata/catcher/InputExceptionCatcher.java b/src/org/kar/archidata/catcher/InputExceptionCatcher.java index 1f62204..d0d2407 100644 --- a/src/org/kar/archidata/catcher/InputExceptionCatcher.java +++ b/src/org/kar/archidata/catcher/InputExceptionCatcher.java @@ -8,9 +8,19 @@ import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import jakarta.ws.rs.ext.ExceptionMapper; +/** + * This class catches InputException and maps it to a HTTP response. + */ public class InputExceptionCatcher implements ExceptionMapper { private static final Logger LOGGER = LoggerFactory.getLogger(InputExceptionCatcher.class); + /** + * This method is called when an InputException is thrown. + * It logs the exception and builds a response with the error details. + * + * @param exception the InputException that was thrown + * @return a Response object containing the error details + */ @Override public Response toResponse(final InputException exception) { LOGGER.warn("Catch InputException:"); @@ -21,6 +31,12 @@ public class InputExceptionCatcher implements ExceptionMapper { return Response.status(exception.status).entity(ret).type(MediaType.APPLICATION_JSON).build(); } + /** + * This method builds a RestErrorResponse object from the InputException. + * + * @param exception the InputException that was thrown + * @return a RestErrorResponse object containing the error details + */ private RestErrorResponse build(final InputException exception) { return new RestErrorResponse(exception.status, "Error on input='" + exception.missingVariable + "'", exception.getMessage()); diff --git a/src/org/kar/archidata/catcher/JacksonExceptionCatcher.java b/src/org/kar/archidata/catcher/JacksonExceptionCatcher.java index 2b46aff..30e283f 100644 --- a/src/org/kar/archidata/catcher/JacksonExceptionCatcher.java +++ b/src/org/kar/archidata/catcher/JacksonExceptionCatcher.java @@ -12,6 +12,13 @@ import jakarta.ws.rs.ext.ExceptionMapper; public class JacksonExceptionCatcher implements ExceptionMapper { private static final Logger LOGGER = LoggerFactory.getLogger(JacksonExceptionCatcher.class); + /** + * This method is called when a JacksonException is thrown. + * It logs the exception, builds a response with the error details, and returns it. + * + * @param exception the JacksonException that was thrown + * @return a Response object containing the error details + */ @Override public Response toResponse(final JacksonException exception) { LOGGER.warn("Catch exception Input data parsing:"); @@ -22,6 +29,12 @@ public class JacksonExceptionCatcher implements ExceptionMapper