Package com.google.android.exoplayer2.upstream

## Class DataSourceException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - java.io.IOException
      - - com.google.android.exoplayer2.upstream.DataSourceException

- All Implemented Interfaces:
    `Serializable`
  Direct Known Subclasses:
    `AssetDataSource.AssetDataSourceException`, `ContentDataSource.ContentDataSourceException`, `FileDataSource.FileDataSourceException`, `HttpDataSource.HttpDataSourceException`, `RawResourceDataSource.RawResourceDataSourceException`, `UdpDataSource.UdpDataSourceException`

      public class DataSourceException
      extends IOException

  Used to specify reason of a DataSource error.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static int` | `POSITION_OUT_OF_RANGE` | Deprecated. Use `PlaybackException.ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE`.
    `int` | `reason` | The reason of this `DataSourceException`, should be one of the `ERROR_CODE_IO_*` in `PlaybackException.ErrorCode`.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DataSourceException​(int reason)` | Constructs a DataSourceException.
    `DataSourceException​(String message, int reason)` | Constructs a DataSourceException.
    `DataSourceException​(String message, Throwable cause, int reason)` | Constructs a DataSourceException.
    `DataSourceException​(Throwable cause, int reason)` | Constructs a DataSourceException.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static boolean` | `isCausedByPositionOutOfRange​(IOException e)` | Returns whether the given `IOException` was caused by a `DataSourceException` whose `reason` is `PlaybackException.ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE` in its cause stack.

    - ### 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

    - #### POSITION_OUT_OF_RANGE

          @Deprecated
          public static final int POSITION_OUT_OF_RANGE

      Deprecated.
      Use `PlaybackException.ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE`.
      Indicates that the `starting position` of the request was outside the bounds of the data.
      See Also:
        Constant Field Values

    - #### reason

          @ErrorCode
          public final int reason

      The reason of this `DataSourceException`, should be one of the `ERROR_CODE_IO_*` in `PlaybackException.ErrorCode`.

  - ### Constructor Detail

    - #### DataSourceException

          public DataSourceException​(@ErrorCode
                                     int reason)

      Constructs a DataSourceException.
      Parameters:
        `reason` - Reason of the error, should be one of the `ERROR_CODE_IO_*` in `PlaybackException.ErrorCode`.

    - #### DataSourceException

          public DataSourceException​(@Nullable
                                     Throwable cause,
                                     @ErrorCode
                                     int reason)

      Constructs a DataSourceException.
      Parameters:
        `cause` - The error cause.
        `reason` - Reason of the error, should be one of the `ERROR_CODE_IO_*` in `PlaybackException.ErrorCode`.

    - #### DataSourceException

          public DataSourceException​(@Nullable
                                     String message,
                                     @ErrorCode
                                     int reason)

      Constructs a DataSourceException.
      Parameters:
        `message` - The error message.
        `reason` - Reason of the error, should be one of the `ERROR_CODE_IO_*` in `PlaybackException.ErrorCode`.

    - #### DataSourceException

          public DataSourceException​(@Nullable
                                     String message,
                                     @Nullable
                                     Throwable cause,
                                     @ErrorCode
                                     int reason)

      Constructs a DataSourceException.
      Parameters:
        `message` - The error message.
        `cause` - The error cause.
        `reason` - Reason of the error, should be one of the `ERROR_CODE_IO_*` in `PlaybackException.ErrorCode`.

  - ### Method Detail

    - #### isCausedByPositionOutOfRange

          public static boolean isCausedByPositionOutOfRange​(IOException e)

      Returns whether the given `IOException` was caused by a `DataSourceException` whose `reason` is `PlaybackException.ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE` in its cause stack.