Record Class ODataError

java.lang.Object
java.lang.Record
io.skipcheck.tm1.client.error.ODataError
Record Components:
code - the error code, as text
message - the message
target - what the error applies to, or null
details - further errors, possibly empty
innerError - service-specific detail, or null

public record ODataError(String code, String message, @Nullable String target, List<ODataError> details, @Nullable tools.jackson.databind.JsonNode innerError) extends Record
An OData error response body: {"error":{"code":"278","message":"..."}}.

TM1 uses code 278 for most errors (not found, bad request, precondition failed and not implemented alike), so the code alone rarely identifies an error. See Tm1ErrorClassifier.

  • Constructor Summary

    Constructors
    Constructor
    Description
    ODataError(String code, String message, @Nullable String target, List<ODataError> details, @Nullable tools.jackson.databind.JsonNode innerError)
    Replaces a null code or message with an empty string and copies the details.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the code record component.
    Returns the value of the details record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    static @Nullable ODataError
    from(@Nullable tools.jackson.databind.JsonNode body)
    Reads an error from a response body, if it is one: either {"error":{...}} or the inner object.
    static @Nullable ODataError
    Reads an error from a plain-text body, as TM1 sends for some failures (impersonation, for one): a status line such as Error: Bad Request, then the message.
    final int
    Returns a hash code value for this object.
    @Nullable tools.jackson.databind.JsonNode
    Returns the value of the innerError record component.
    Returns the value of the message record component.
    @Nullable String
    Returns the value of the target record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ODataError

      public ODataError(String code, String message, @Nullable String target, List<ODataError> details, @Nullable tools.jackson.databind.JsonNode innerError)
      Replaces a null code or message with an empty string and copies the details.
  • Method Details

    • from

      public static @Nullable ODataError from(@Nullable tools.jackson.databind.JsonNode body)
      Reads an error from a response body, if it is one: either {"error":{...}} or the inner object.
      Parameters:
      body - a response body, or null
      Returns:
      the error, or null if the body isn't an object with a code or message
    • fromText

      public static @Nullable ODataError fromText(String body)
      Reads an error from a plain-text body, as TM1 sends for some failures (impersonation, for one): a status line such as Error: Bad Request, then the message. The status line is dropped, and the remaining lines become the message, with no code.
      Parameters:
      body - the response body as text
      Returns:
      the error, or null if the body has no message
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • code

      public String code()
      Returns the value of the code record component.
      Returns:
      the value of the code record component
    • message

      public String message()
      Returns the value of the message record component.
      Returns:
      the value of the message record component
    • target

      public @Nullable String target()
      Returns the value of the target record component.
      Returns:
      the value of the target record component
    • details

      public List<ODataError> details()
      Returns the value of the details record component.
      Returns:
      the value of the details record component
    • innerError

      public @Nullable tools.jackson.databind.JsonNode innerError()
      Returns the value of the innerError record component.
      Returns:
      the value of the innerError record component