Package com.castlabs.android.drm

# Class DrmTodayException

java.lang.Object
java.lang.Throwable
java.lang.Exception
com.castlabs.android.drm.DrmTodayException

All Implemented Interfaces:
  `Serializable`

public class DrmTodayException extends Exception
Use this Exception class to report any errors from DrmToday services. The exception is initialized with an error code which is one of: `ERROR_NOT_AUTHORIZED`, `ERROR_INVALID_REQUEST`, `ERROR_KEY_NOT_FOUND`, `ERROR_PROVISIONING_FAILED`, `ERROR_TOO_MANY_CONCURRENT_SESSIONS`, or `ERROR_UNKNOWN`. The exception can also contain a custom message and code from the DrmToday service.

See Also:
  - Serialized Form

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static @interface`
  `DrmTodayException.ErrorCode`
  Annotation interface for error codes used in DrmTodayException.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `ERROR_DEVICE_TIME`
  A device time error occurred
  `static final int`
  `ERROR_INVALID_REQUEST`
  Error indicating an invalid request that was rejected by the server
  `static final int`
  `ERROR_IO_ERROR`
  Error indicating that an IO error occurred during the license request.
  `static final int`
  `ERROR_KEY_NOT_FOUND`
  Error indicating that the requested content was not found
  `static final int`
  `ERROR_NOT_AUTHORIZED`
  Error indicating an unauthorized request
  `static final int`
  `ERROR_PROVISIONING_FAILED`
  Error indicating that the provisioning request failed.
  `static final int`
  `ERROR_TOO_MANY_CONCURRENT_SESSIONS`
  Error raised when DRMtoday refuses license renewal due to too many open sessions
  `static final int`
  `ERROR_UNKNOWN`
  Error indicating a general error
  `static final int`
  `ERROR_WIDEVINE_DEV_CERTIFICATE_REVOKED`
  A device's Widevine certificate was revoked

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DrmTodayException(String message, int errorCode)`
  Create a new instance with the given message and error errorCode
  `DrmTodayException(String message, int errorCode, String customMessage)`
  Create a new instance with the given message and error errorCode
  `DrmTodayException(String message, int errorCode, String customMessage, String customCode, Throwable cause)`
  Create a new instance
  `DrmTodayException(String message, int errorCode, Throwable cause)`
  Create a new instance with the given message and error errorCode

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static DrmTodayException`
  `create(DrmUtils.HttpExecutorException httpException)`
  Looks at the response code, the response body, and the headers and returns a DrmToday Exception that maps to the given error.
  `String`
  `getCustomCode()`
  Returns the custom DrmToday response code string, if available.
  `String`
  `getCustomMessage()`
  Returns the custom CRT error message, if available.
  `int`
  `getErrorCode()`
  Returns the error code of this exception.
  `String`
  `getTraceId()`
  Returns the trace identifier returned by DRMToday, if available.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Throwable

  `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### ERROR_UNKNOWN

    public static final int ERROR_UNKNOWN
    Error indicating a general error
    See Also:
      - Constant Field Values

  - ### ERROR_INVALID_REQUEST

    public static final int ERROR_INVALID_REQUEST
    Error indicating an invalid request that was rejected by the server
    See Also:
      - Constant Field Values

  - ### ERROR_NOT_AUTHORIZED

    public static final int ERROR_NOT_AUTHORIZED
    Error indicating an unauthorized request
    See Also:
      - Constant Field Values

  - ### ERROR_KEY_NOT_FOUND

    public static final int ERROR_KEY_NOT_FOUND
    Error indicating that the requested content was not found
    See Also:
      - Constant Field Values

  - ### ERROR_IO_ERROR

    public static final int ERROR_IO_ERROR
    Error indicating that an IO error occurred during the license request. This cause of this exception will be an `IOException`
    See Also:
      - Constant Field Values

  - ### ERROR_PROVISIONING_FAILED

    public static final int ERROR_PROVISIONING_FAILED
    Error indicating that the provisioning request failed. Error of this type can also have an `IOException` as cause.
    See Also:
      - Constant Field Values

  - ### ERROR_TOO_MANY_CONCURRENT_SESSIONS

    public static final int ERROR_TOO_MANY_CONCURRENT_SESSIONS
    Error raised when DRMtoday refuses license renewal due to too many open sessions
    See Also:
      - Constant Field Values

  - ### ERROR_DEVICE_TIME

    public static final int ERROR_DEVICE_TIME
    A device time error occurred
    See Also:
      - Constant Field Values

  - ### ERROR_WIDEVINE_DEV_CERTIFICATE_REVOKED

    public static final int ERROR_WIDEVINE_DEV_CERTIFICATE_REVOKED
    A device's Widevine certificate was revoked
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### DrmTodayException

    public DrmTodayException(@NonNull String message, int errorCode)
    Create a new instance with the given message and error errorCode
    Parameters:
      `message` - the error message
      `errorCode` - the error errorCode

  - ### DrmTodayException

    public DrmTodayException(@NonNull String message, int errorCode, @Nullable String customMessage)
    Create a new instance with the given message and error errorCode
    Parameters:
      `message` - the error message
      `errorCode` - the error errorCode
      `customMessage` - the custom message

  - ### DrmTodayException

    public DrmTodayException(@NonNull String message, int errorCode, Throwable cause)
    Create a new instance with the given message and error errorCode
    Parameters:
      `message` - the error message
      `errorCode` - the error errorCode
      `cause` - the cause

  - ### DrmTodayException

    public DrmTodayException(@NonNull String message, int errorCode, @Nullable String customMessage, @Nullable String customCode, Throwable cause)
    Create a new instance
    Parameters:
      `message` - the error message
      `errorCode` - the error errorCode
      `customMessage` - the custom message
      `customCode` - the custom code
      `cause` - the cause

- ## Method Details

  - ### getErrorCode

    public int getErrorCode()
    Returns the error code of this exception.
    Returns:
      The error code. One of `ERROR_NOT_AUTHORIZED`, `ERROR_INVALID_REQUEST`, `ERROR_UNKNOWN`, `ERROR_TOO_MANY_CONCURRENT_SESSIONS`, or `ERROR_KEY_NOT_FOUND`

  - ### getCustomMessage

    @Nullable public String getCustomMessage()
    Returns the custom CRT error message, if available.
    Returns:
      The custom CRT error message or null

  - ### getCustomCode

    @Nullable public String getCustomCode()
    Returns the custom DrmToday response code string, if available.
    Returns:
      DrmToday response code string, or null if not available

  - ### getTraceId

    @Nullable public String getTraceId()
    Returns the trace identifier returned by DRMToday, if available.
    Returns:
      Trace identifier string, or null when the response did not expose one

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Throwable`

  - ### create

    @NonNull public static DrmTodayException create(@NonNull DrmUtils.HttpExecutorException httpException)
    Looks at the response code, the response body, and the headers and returns a DrmToday Exception that maps to the given error.
    Parameters:
      `httpException` - The HTTP exception
    Returns:
      The DrmTodayException