Record Class Problem

java.lang.Object
java.lang.Record
co.cryptoservice.sdk.Problem
Record Components:
type - urn:crypto-service:problem:<slug>, or about:blank when the server sent no problem body
title - a short summary of the problem type
status - the HTTP status
detail - an explanation of this occurrence
instance - the request path, or null
code - the machine-readable code for crypto-lib, key-store and KMS errors (for example AUTH_FAILED, KEY_NOT_FOUND), or null
errors - each field that failed validation (validation-failed); empty otherwise
extensions - every other member (for example limit and resetSeconds on a tenant quota problem), in the order sent

public record Problem(String type, String title, int status, String detail, String instance, String code, List<ValidationError> errors, Map<String,com.fasterxml.jackson.databind.JsonNode> extensions) extends Record
An RFC 9457 problem: the body of every error the server sends (application/problem+json).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The type of a problem the client made up for a body that was not one.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Problem(String type, String title, int status, String detail, String instance, String code, List<ValidationError> errors, Map<String,com.fasterxml.jackson.databind.JsonNode> extensions)
    Copies the lists and maps so the problem is immutable.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Problem
    blank(int status)
    The problem the client uses when the body is not one.
    Returns the value of the code record component.
    Returns the value of the detail record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the errors record component.
    Map<String,com.fasterxml.jackson.databind.JsonNode>
    Returns the value of the extensions record component.
    final int
    Returns a hash code value for this object.
    Returns the value of the instance record component.
    static Problem
    parse(byte[] body, int status)
    Reads a problem from an error response body.
    int
    Returns the value of the status record component.
    Returns the value of the title record component.
    Names the type, status, code and instance, counts the validation errors and names the extension members; detail and the validation messages are left out, as they describe the request.
    Returns the value of the type record component.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • ABOUT_BLANK

      public static final String ABOUT_BLANK
      The type of a problem the client made up for a body that was not one.
      See Also:
  • Constructor Details

  • Method Details

    • parse

      public static Problem parse(byte[] body, int status)
      Reads a problem from an error response body. A body that is not a JSON object with a string detail (the test the TypeScript SDK applies) becomes an about:blank problem for status.
      Parameters:
      body - the response body
      status - the response status
      Returns:
      the problem; never null, and never throws
    • blank

      public static Problem blank(int status)
      The problem the client uses when the body is not one.
      Parameters:
      status - the response status
      Returns:
      an about:blank problem
    • toString

      public String toString()
      Names the type, status, code and instance, counts the validation errors and names the extension members; detail and the validation messages are left out, as they describe the request.
      Specified by:
      toString in class Record
      Returns:
      a description safe to log
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • type

      public String type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • title

      public String title()
      Returns the value of the title record component.
      Returns:
      the value of the title record component
    • status

      public int status()
      Returns the value of the status record component.
      Returns:
      the value of the status record component
    • detail

      public String detail()
      Returns the value of the detail record component.
      Returns:
      the value of the detail record component
    • instance

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

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

      public List<ValidationError> errors()
      Returns the value of the errors record component.
      Returns:
      the value of the errors record component
    • extensions

      public Map<String,com.fasterxml.jackson.databind.JsonNode> extensions()
      Returns the value of the extensions record component.
      Returns:
      the value of the extensions record component