Package com.castlabs.android.player.exceptions

# Class DownloadException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.io.IOException
com.castlabs.android.player.exceptions.DownloadException

All Implemented Interfaces:
  `Serializable`

public class DownloadException extends IOException
Exception that is raised when media download errors occur. You can use `getTrackType()` to identify the track that caused the error.

Since:
  3.0.0
See Also:
  - Serialized Form

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static DownloadException`
  `create(int trackType, Throwable cause)`
  Creates a new DownloadException with the specified track type and cause.
  `static DownloadException`
  `create(Throwable cause)`
  Creates a new DownloadException from a Throwable, automatically determining the track type if possible from the cause.
  `String`
  `getMessage()`
  `byte[]`
  `getResponseBody()`
  Gets the response body from the failed request.
  `int`
  `getStatusCode()`
  Gets the HTTP status code from the failed request.
  `int`
  `getTrackType()`
  Gets the type of track that caused the download error.
  `Uri`
  `getUri()`
  The underlying URI that caused the error.

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

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

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

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

- ## Method Details

  - ### create

    @NonNull public static DownloadException create(@NonNull Throwable cause)
    Creates a new DownloadException from a Throwable, automatically determining the track type if possible from the cause.
    Parameters:
      `cause` - The underlying exception that caused the download error
    Returns:
      A new DownloadException instance

  - ### create

    @NonNull public static DownloadException create(int trackType, @NonNull Throwable cause)
    Creates a new DownloadException with the specified track type and cause.
    Parameters:
      `trackType` - The type of track that caused the error
      `cause` - The underlying exception that caused the download error
    Returns:
      A new DownloadException instance

  - ### getUri

    @Nullable public Uri getUri()
    The underlying URI that caused the error. This might be null.
    Returns:
      The URI or null

  - ### getStatusCode

    public int getStatusCode()
    Gets the HTTP status code from the failed request.
    Returns:
      The response status code or -1 if not applicable

  - ### getResponseBody

    @Nullable public byte[] getResponseBody()
    Gets the response body from the failed request.
    Returns:
      The response body, or null if not available

  - ### getTrackType

    public int getTrackType()
    Gets the type of track that caused the download error.
    Returns:
      The type of the track that caused the error. One of `PlayerController.VIDEO_RENDERER`, `PlayerController.AUDIO_RENDERER`, `PlayerController.TEXT_RENDERER` or `PlayerController.METADATA_RENDERER`

  - ### getMessage

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