Class FormattedError

java.lang.Object
gov.nasa.jpl.aerie.json.FormattedError

public class FormattedError extends Object
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
  • Constructor Details

    • FormattedError

      public FormattedError(FormattedError.AerieService service, String message)
      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

      public 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

      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

      public FormattedError(FormattedError.AerieService service, String type, Exception ex)
      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_CASE
      ex - 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_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.
      data - the additional data to be included
    • FormattedError

      public FormattedError(FormattedError.AerieService service, IOException nse)
    • FormattedError

      public FormattedError(FormattedError.AerieService service, IOException nse, String message)
    • FormattedError

      public FormattedError(FormattedError.AerieService service, SQLException se)
    • FormattedError

      public FormattedError(FormattedError.AerieService service, SQLException se, String message)
    • FormattedError

      public FormattedError(FormattedError.AerieService service, io.javalin.http.UnauthorizedResponse ue)
    • FormattedError

      public FormattedError(FormattedError.AerieService service, NumberFormatException nfe)
    • FormattedError

      public FormattedError(FormattedError.AerieService service, IllegalArgumentException iae)
    • FormattedError

      public FormattedError(FormattedError.AerieService service, javax.json.JsonException je)
    • FormattedError

      public FormattedError(FormattedError.AerieService service, javax.json.JsonException je, String message)
    • FormattedError

      public FormattedError(FormattedError.AerieService service, io.javalin.validation.ValidationException ve)
    • FormattedError

      public FormattedError(FormattedError.AerieService service, NullPointerException ne, String message)
    • FormattedError

      public FormattedError(FormattedError.AerieService service, SecurityException se)
  • Method Details

    • getType

      public String getType()
    • getMessage

      public String getMessage()
    • toJson

      public javax.json.JsonObject toJson()
      Export this object to a JsonObject.
    • toString

      public String toString()
      Overrides:
      toString in class Object