Class JsonException

  • All Implemented Interfaces:
    java.io.Serializable

    public class JsonException
    extends java.lang.Exception
    Throw an exception, but include an HTTP error code.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CODE
      "code"
      static java.lang.String ERROR
      "error"
      static java.lang.String ERROR_BAD_PROPERTY_VALUE
      "ErrorBadPropertyValue", a key for localized error messages indicating the value for the given property is not valid.
      static java.lang.String ERROR_MISSING_PROPERTY_PUT
      "ErrorMissingPropertyPut", a key for localized error messages indicating a property required to complete a PUT request is missing.
      static java.lang.String ERROR_NOT_FOUND
      "ErrorNotFound", a key for localized error messages indicating a resource was not found.
      static java.lang.String ERROR_OBJECT
      "ErrorObject", a key for localized error messages indicating an inability to get a requested object.
      static java.lang.String ERROR_UNKNOWN_TYPE
      "ErrorUnknownType", a key for localized error messages indicating the requested type cannot be handled.
      static java.lang.String LOGGED_ERROR
      "LoggedError", a key for localized error messages indicating that JMRI logs contain required information to resolve the error.
      static java.lang.String MESSAGE
      "message"
    • Constructor Summary

      Constructors 
      Constructor Description
      JsonException​(int code, java.lang.String message, int id)
      Create an exception that can be passed to a JSON client.
      JsonException​(int code, java.lang.String message, com.fasterxml.jackson.databind.node.ObjectNode additionalData, int id)
      Create an exception that can be passed to a JSON client.
      JsonException​(int code, java.lang.String message, java.lang.Throwable throwable, int id)
      Create an exception that can be passed to a JSON client.
      JsonException​(int code, java.lang.String message, java.lang.Throwable throwable, com.fasterxml.jackson.databind.node.ObjectNode additionalData, int id)
      Create an exception that can be passed to a JSON client.
      JsonException​(int code, java.lang.Throwable throwable, int id)
      Create an exception that can be passed to a JSON client.
      JsonException​(int code, java.lang.Throwable throwable, com.fasterxml.jackson.databind.node.ObjectNode additionalData, int id)
      Create an exception that can be passed to a JSON client.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.fasterxml.jackson.databind.node.ObjectNode getAdditionalData()
      Get any additional data passed to the client.
      int getCode()
      Get the error code (usually an HTTP error code)
      int getId()
      Get the id passed to the client.
      com.fasterxml.jackson.databind.JsonNode getJsonMessage()
      Get the JSON formatted error message.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • JsonException

        public JsonException​(int code,
                             java.lang.String message,
                             java.lang.Throwable throwable,
                             int id)
        Create an exception that can be passed to a JSON client.
        Parameters:
        code - the error code
        message - message, displayable to the user, in the client's preferred locale
        throwable - the cause of the exception
        id - the message id passed by the client, or the additive inverse of that id
      • JsonException

        public JsonException​(int code,
                             java.lang.String message,
                             java.lang.Throwable throwable,
                             com.fasterxml.jackson.databind.node.ObjectNode additionalData,
                             int id)
        Create an exception that can be passed to a JSON client.
        Parameters:
        code - the error code
        message - message, displayable to the user, in the client's preferred locale
        throwable - the cause of the exception
        additionalData - additional data to be passed to the client
        id - the message id passed by the client, or the additive inverse of that id
      • JsonException

        public JsonException​(int code,
                             java.lang.Throwable throwable,
                             int id)
        Create an exception that can be passed to a JSON client.
        Parameters:
        code - the error code
        throwable - the cause of the exception
        id - the message id passed by the client, or the additive inverse of that id
      • JsonException

        public JsonException​(int code,
                             java.lang.Throwable throwable,
                             com.fasterxml.jackson.databind.node.ObjectNode additionalData,
                             int id)
        Create an exception that can be passed to a JSON client.
        Parameters:
        code - the error code
        throwable - the cause of the exception
        additionalData - additional data to be passed to the client
        id - the message id passed by the client, or the additive inverse of that id
      • JsonException

        public JsonException​(int code,
                             java.lang.String message,
                             int id)
        Create an exception that can be passed to a JSON client.
        Parameters:
        code - the error code
        message - message, displayable to the user, in the client's preferred locale
        id - the message id passed by the client, or the additive inverse of that id
      • JsonException

        public JsonException​(int code,
                             java.lang.String message,
                             com.fasterxml.jackson.databind.node.ObjectNode additionalData,
                             int id)
        Create an exception that can be passed to a JSON client.
        Parameters:
        code - the error code
        message - message, displayable to the user, in the client's preferred locale
        additionalData - additional data to be passed to the client
        id - the message id passed by the client, or the additive inverse of that id
    • Method Detail

      • getCode

        public int getCode()
        Get the error code (usually an HTTP error code)
        Returns:
        the code
      • getAdditionalData

        public com.fasterxml.jackson.databind.node.ObjectNode getAdditionalData()
        Get any additional data passed to the client. This is specific to, and will vary based on, the original exception.
        Returns:
        the additional data or null if none
      • getId

        public int getId()
        Get the id passed to the client.
        Returns:
        the absolute value of the id
        See Also:
        JsonHttpService
      • getJsonMessage

        public com.fasterxml.jackson.databind.JsonNode getJsonMessage()
        Get the JSON formatted error message.
        Returns:
        the error message in a JSON format