Class Tm1ErrorClassifier

java.lang.Object
io.skipcheck.tm1.client.error.Tm1ErrorClassifier

public final class Tm1ErrorClassifier extends Object
Works out a Tm1ErrorKind from an error response.

TM1's error codes rarely say what went wrong: code 278 covers most failures. So classification is a table of rules, tried in order, matching on HTTP status, code and message. The first match wins, and the HTTP status decides when nothing matches. Matching on message text is a last resort, but TM1 gives nothing better for several errors (impersonation failures, for instance).

The table is data: defaults() holds the rules this client knows, and withRule(Tm1ErrorClassifier.Rule) adds your own in front of them, e.g. for a message your TM1 version phrases differently.

  • Method Details

    • defaults

      public static Tm1ErrorClassifier defaults()
      The rules this client knows about.
      Returns:
      the default classifier
    • withRule

      A classifier trying rule before these rules.
      Parameters:
      rule - the rule to try first
      Returns:
      a new classifier; this one is unchanged
    • classify

      public Tm1ErrorKind classify(int status, @Nullable ODataError error)
      Classifies an error response; error may be null if the body wasn't an OData error.
      Parameters:
      status - the HTTP status
      error - the parsed error body, or null
      Returns:
      the first matching rule's kind, or else the kind for the status (Tm1ErrorKind.OTHER if it has none)