Package com.google.android.exoplayer2

## Class ExoPlaybackException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - com.google.android.exoplayer2.ExoPlaybackException

- All Implemented Interfaces:
    `Bundleable`, `Serializable`

      public final class ExoPlaybackException
      extends Exception
      implements Bundleable

  Thrown when a non locally recoverable playback failure occurs.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static interface` | `ExoPlaybackException.Type` | The type of source that produced the error.

    - ### Nested classes/interfaces inherited from interface com.google.android.exoplayer2.Bundleable

      `Bundleable.Creator<T extends Bundleable>`

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static Bundleable.Creator<ExoPlaybackException>` | `CREATOR` | Object that can restore `ExoPlaybackException` from a `Bundle`.
    `MediaPeriodId` | `mediaPeriodId` | The `MediaPeriodId` of the media associated with this error, or null if undetermined.
    `Format` | `rendererFormat` | If `type` is `TYPE_RENDERER`, this is the `Format` the renderer was using at the time of the exception, or null if the renderer wasn't using a `Format`.
    `int` | `rendererFormatSupport` | If `type` is `TYPE_RENDERER`, this is the level of `C.FormatSupport` of the renderer for `rendererFormat`.
    `int` | `rendererIndex` | If `type` is `TYPE_RENDERER`, this is the index of the renderer, or `C.INDEX_UNSET` if unknown.
    `String` | `rendererName` | If `type` is `TYPE_RENDERER`, this is the name of the renderer, or null if unknown.
    `long` | `timestampMs` | The value of `SystemClock.elapsedRealtime()` when this exception was created.
    `int` | `type` | The `ExoPlaybackException.Type` of the playback failure.
    `static int` | `TYPE_REMOTE` | The error occurred in a remote component.
    `static int` | `TYPE_RENDERER` | The error occurred in a `Renderer`.
    `static int` | `TYPE_SOURCE` | The error occurred loading data from a `MediaSource`.
    `static int` | `TYPE_UNEXPECTED` | The error was an unexpected `RuntimeException`.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static ExoPlaybackException` | `createForRemote​(String message)` | Creates an instance of type `TYPE_REMOTE`.
    `static ExoPlaybackException` | `createForRenderer​(Exception cause)` | Creates an instance of type `TYPE_RENDERER` for an unknown renderer.
    `static ExoPlaybackException` | `createForRenderer​(Throwable cause, String rendererName, int rendererIndex, Format rendererFormat, int rendererFormatSupport)` | Creates an instance of type `TYPE_RENDERER`.
    `static ExoPlaybackException` | `createForRenderer​(Throwable cause, String rendererName, int rendererIndex, Format rendererFormat, int rendererFormatSupport, boolean isRecoverable)` | Creates an instance of type `TYPE_RENDERER`.
    `static ExoPlaybackException` | `createForSource​(IOException cause)` | Creates an instance of type `TYPE_SOURCE`.
    `static ExoPlaybackException` | `createForUnexpected​(RuntimeException cause)` | Creates an instance of type `TYPE_UNEXPECTED`.
    `Exception` | `getRendererException()` | Retrieves the underlying error when `type` is `TYPE_RENDERER`.
    `IOException` | `getSourceException()` | Retrieves the underlying error when `type` is `TYPE_SOURCE`.
    `RuntimeException` | `getUnexpectedException()` | Retrieves the underlying error when `type` is `TYPE_UNEXPECTED`.
    `Bundle` | `toBundle()` | Returns a `Bundle` representing the information stored in this object.

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

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

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

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

- - ### Field Detail

    - #### TYPE_SOURCE

          public static final int TYPE_SOURCE

      The error occurred loading data from a `MediaSource`.

      Call `getSourceException()` to retrieve the underlying cause.

      See Also:
        Constant Field Values

    - #### TYPE_RENDERER

          public static final int TYPE_RENDERER

      The error occurred in a `Renderer`.

      Call `getRendererException()` to retrieve the underlying cause.

      See Also:
        Constant Field Values

    - #### TYPE_UNEXPECTED

          public static final int TYPE_UNEXPECTED

      The error was an unexpected `RuntimeException`.

      Call `getUnexpectedException()` to retrieve the underlying cause.

      See Also:
        Constant Field Values

    - #### TYPE_REMOTE

          public static final int TYPE_REMOTE

      The error occurred in a remote component.

      Call `Throwable.getMessage()` to retrieve the message associated with the error.

      See Also:
        Constant Field Values

    - #### type

          @Type
          public final int type

      The `ExoPlaybackException.Type` of the playback failure.

    - #### rendererName

          @Nullable
          public final String rendererName

      If `type` is `TYPE_RENDERER`, this is the name of the renderer, or null if unknown.

    - #### rendererIndex

          public final int rendererIndex

      If `type` is `TYPE_RENDERER`, this is the index of the renderer, or `C.INDEX_UNSET` if unknown.

    - #### rendererFormat

          @Nullable
          public final Format rendererFormat

      If `type` is `TYPE_RENDERER`, this is the `Format` the renderer was using at the time of the exception, or null if the renderer wasn't using a `Format`.

    - #### rendererFormatSupport

          @FormatSupport
          public final int rendererFormatSupport

      If `type` is `TYPE_RENDERER`, this is the level of `C.FormatSupport` of the renderer for `rendererFormat`. If `rendererFormat` is null, this is `C.FORMAT_HANDLED`.

    - #### timestampMs

          public final long timestampMs

      The value of `SystemClock.elapsedRealtime()` when this exception was created.

    - #### mediaPeriodId

          @Nullable
          public final MediaPeriodId mediaPeriodId

      The `MediaPeriodId` of the media associated with this error, or null if undetermined.

    - #### CREATOR

          public static final Bundleable.Creator<ExoPlaybackException> CREATOR

      Object that can restore `ExoPlaybackException` from a `Bundle`.

  - ### Method Detail

    - #### createForSource

          public static ExoPlaybackException createForSource​(IOException cause)

      Creates an instance of type `TYPE_SOURCE`.
      Parameters:
        `cause` - The cause of the failure.
      Returns:
        The created instance.

    - #### createForRenderer

          public static ExoPlaybackException createForRenderer​(Exception cause)

      Creates an instance of type `TYPE_RENDERER` for an unknown renderer.
      Parameters:
        `cause` - The cause of the failure.
      Returns:
        The created instance.

    - #### createForRenderer

          public static ExoPlaybackException createForRenderer​(Throwable cause,
                                                               String rendererName,
                                                               int rendererIndex,
                                                               @Nullable
                                                               Format rendererFormat,
                                                               @FormatSupport
                                                               int rendererFormatSupport)

      Creates an instance of type `TYPE_RENDERER`.
      Parameters:
        `cause` - The cause of the failure.
        `rendererIndex` - The index of the renderer in which the failure occurred.
        `rendererFormat` - The `Format` the renderer was using at the time of the exception, or null if the renderer wasn't using a `Format`.
        `rendererFormatSupport` - The `C.FormatSupport` of the renderer for `rendererFormat`. Ignored if `rendererFormat` is null.
      Returns:
        The created instance.

    - #### createForRenderer

          public static ExoPlaybackException createForRenderer​(Throwable cause,
                                                               String rendererName,
                                                               int rendererIndex,
                                                               @Nullable
                                                               Format rendererFormat,
                                                               @FormatSupport
                                                               int rendererFormatSupport,
                                                               boolean isRecoverable)

      Creates an instance of type `TYPE_RENDERER`.
      Parameters:
        `cause` - The cause of the failure.
        `rendererIndex` - The index of the renderer in which the failure occurred.
        `rendererFormat` - The `Format` the renderer was using at the time of the exception, or null if the renderer wasn't using a `Format`.
        `rendererFormatSupport` - The `C.FormatSupport` of the renderer for `rendererFormat`. Ignored if `rendererFormat` is null.
        `isRecoverable` - If the failure can be recovered by disabling and re-enabling the renderer.
      Returns:
        The created instance.

    - #### createForUnexpected

          public static ExoPlaybackException createForUnexpected​(RuntimeException cause)

      Creates an instance of type `TYPE_UNEXPECTED`.
      Parameters:
        `cause` - The cause of the failure.
      Returns:
        The created instance.

    - #### createForRemote

          public static ExoPlaybackException createForRemote​(String message)

      Creates an instance of type `TYPE_REMOTE`.
      Parameters:
        `message` - The message associated with the error.
      Returns:
        The created instance.

    - #### getSourceException

          public IOException getSourceException()

      Retrieves the underlying error when `type` is `TYPE_SOURCE`.
      Throws:
        `IllegalStateException` - If `type` is not `TYPE_SOURCE`.

    - #### getRendererException

          public Exception getRendererException()

      Retrieves the underlying error when `type` is `TYPE_RENDERER`.
      Throws:
        `IllegalStateException` - If `type` is not `TYPE_RENDERER`.

    - #### getUnexpectedException

          public RuntimeException getUnexpectedException()

      Retrieves the underlying error when `type` is `TYPE_UNEXPECTED`.
      Throws:
        `IllegalStateException` - If `type` is not `TYPE_UNEXPECTED`.

    - #### toBundle

          public Bundle toBundle()

      Returns a `Bundle` representing the information stored in this object.

      It omits the `mediaPeriodId` field. The `mediaPeriodId` of an instance restored by `CREATOR` will always be `null`.

      Specified by:
        `toBundle` in interface `Bundleable`