Package gov.nasa.jpl.aerie.json
Class FormattedError
java.lang.Object
gov.nasa.jpl.aerie.json.FormattedError
Class for formatting exceptions thrown into JSON objects that meet the Aerie HTTP endpoint error message format
Relevant ticket going over said format: https://github.com/NASA-AMMOS/plandev/issues/1732
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic final classInternal class so that Javalin serializes the FormattedError class using its `toJson` method. -
Constructor Summary
ConstructorsConstructorDescriptionFormattedError(FormattedError.AerieService service, io.javalin.http.UnauthorizedResponse ue) FormattedError(FormattedError.AerieService service, io.javalin.validation.ValidationException ve) FormattedError(FormattedError.AerieService service, IOException nse) FormattedError(FormattedError.AerieService service, IOException nse, String message) FormattedError(FormattedError.AerieService service, NullPointerException ne, String message) FormattedError(FormattedError.AerieService service, NumberFormatException nfe) FormattedError(FormattedError.AerieService service, SecurityException se) FormattedError(FormattedError.AerieService service, String message) For use in the event of an endpoint failing without throwing an exception.FormattedError(FormattedError.AerieService service, String type, Exception ex) Create a FormattedException from a generic Exception object.FormattedError(FormattedError.AerieService service, String type, Exception ex, javax.json.JsonValue data) Create a FormattedException with additional data from a generic Exception object.FormattedError(FormattedError.AerieService service, String message, String cause) For use in the event of an endpoint failing without throwing an exception, but where there's a more detailed cause.FormattedError(FormattedError.AerieService service, String type, String message, Exception ex, javax.json.JsonValue data) Create a FormattedException with a custom message and additional data from a generic Exception object.FormattedError(FormattedError.AerieService service, String type, String message, String cause, Exception ex) Create a FormattedException from a generic Exception object with a custom error message and cause.FormattedError(FormattedError.AerieService service, String type, String message, Throwable ex) Create a FormattedException from a generic Exception object with a custom error message.FormattedError(FormattedError.AerieService service, String type, String message, Optional<String> cause) For use in the event of an endpoint failing without throwing an exception, but "INTERNAL_ERROR" does not make sense as the error type (i.e.FormattedError(FormattedError.AerieService service, String type, String message, Optional<String> cause, javax.json.JsonValue data) For use in the event of an endpoint failing without throwing an exception, but where there's a more detailed data object.FormattedError(FormattedError.AerieService service, SQLException se) FormattedError(FormattedError.AerieService service, SQLException se, String message) FormattedError(FormattedError.AerieService service, javax.json.JsonException je) FormattedError(FormattedError.AerieService service, javax.json.JsonException je, String message) -
Method Summary
-
Constructor Details
-
FormattedError
For use in the event of an endpoint failing without throwing an exception. i.e. Workspace's delete file endpoint failing because java.nio.File#deleteFile returned "false" -
FormattedError
For use in the event of an endpoint failing without throwing an exception, but where there's a more detailed cause. -
FormattedError
public FormattedError(FormattedError.AerieService service, String type, String message, Optional<String> cause) For use in the event of an endpoint failing without throwing an exception, but "INTERNAL_ERROR" does not make sense as the error type (i.e. the request is malformed) -
FormattedError
public FormattedError(FormattedError.AerieService service, String type, String message, Optional<String> cause, javax.json.JsonValue data) For use in the event of an endpoint failing without throwing an exception, but where there's a more detailed data object.- Parameters:
service- the service that throw the exception.type- the category of exception. Should be in SCREAMING_SNAKE_CASE.message- the custom error message explaining the cause of the error. Should be human-readable and between 1-2 sentences.cause- the root cause of the exception.
-
FormattedError
Create a FormattedException from a generic Exception object.- Parameters:
service- the service that throw the exception.type- the category of exception. Should be in SCREAMING_SNAKE_CASE.ex- the exception to be formatted.
-
FormattedError
public FormattedError(FormattedError.AerieService service, String type, String message, Throwable ex) Create a FormattedException from a generic Exception object with a custom error message. The exception's built-in error message, if included, will be put into the 'cause' field.- Parameters:
service- the service that throw the exception.type- the category of exception. Should be in SCREAMING_SNAKE_CASE.message- the custom error message explaining the cause of the error. Should be human-readable and between 1-2 sentences.ex- the exception to be formatted.
-
FormattedError
public FormattedError(FormattedError.AerieService service, String type, String message, String cause, Exception ex) Create a FormattedException from a generic Exception object with a custom error message and cause.- Parameters:
service- the service that throw the exception.type- the category of exception. Should be in SCREAMING_SNAKE_CASE.message- the custom error message explaining the cause of the error. Should be human-readable and between 1-2 sentences.cause- the root cause of the exception.ex- the exception to be formatted.
-
FormattedError
public FormattedError(FormattedError.AerieService service, String type, Exception ex, javax.json.JsonValue data) Create a FormattedException with additional data from a generic Exception object.- Parameters:
type- the category of exception. Should be in SCREAMING_SNAKE_CASEex- the exception to be formatted.data- the additional data to be included
-
FormattedError
public FormattedError(FormattedError.AerieService service, String type, String message, Exception ex, javax.json.JsonValue data) Create a FormattedException with a custom message and additional data from a generic Exception object.- Parameters:
type- the category of exception. Should be in SCREAMING_SNAKE_CASEmessage- the custom error message explaining the cause of the error. Should be human-readable and between 1-2 sentences.ex- the exception to be formatted.data- the additional data to be included
-
FormattedError
-
FormattedError
-
FormattedError
-
FormattedError
-
FormattedError
-
FormattedError
-
FormattedError
-
FormattedError
-
FormattedError
public FormattedError(FormattedError.AerieService service, javax.json.JsonException je, String message) -
FormattedError
public FormattedError(FormattedError.AerieService service, io.javalin.validation.ValidationException ve) -
FormattedError
-
FormattedError
-
-
Method Details