# AdsMediaSource.AdLoadException

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/source/ads/AdsMediaSource.java+class:androidx.media3.exoplayer.source.ads.AdsMediaSource.AdLoadException)

*** ** * ** ***


```
public final class AdsMediaSource.AdLoadException extends IOException
```

<br />

|---|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||||
| ↳ | [kotlin.Throwable](https://developer.android.com/reference/java/lang/Throwable.html) ||||
|   | ↳ | [java.lang.Exception](https://developer.android.com/reference/java/lang/Exception.html) |||
|   |   | ↳ | [java.io.IOException](https://developer.android.com/reference/java/io/IOException.html) ||
|   |   |   | ↳ | [androidx.media3.exoplayer.source.ads.AdsMediaSource.AdLoadException](https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException) |

*** ** * ** ***

Wrapper for exceptions that occur while loading ads, which are notified via `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSourceEventListener#onLoadError(int,androidx.media3.exoplayer.source.MediaSource.MediaPeriodId,androidx.media3.exoplayer.source.LoadEventInfo,androidx.media3.exoplayer.source.MediaLoadData,java.io.IOException,boolean)`.

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/androidx/annotation/IntDef(value = ) public annotation https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException.Type` Types of ad load exceptions. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#TYPE_AD() = 0` Type for when an ad failed to load. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#TYPE_AD_GROUP() = 1` Type for when an ad group failed to load. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#TYPE_ALL_ADS() = 2` Type for when all ad groups failed to load. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#TYPE_UNEXPECTED() = 3` Type for when an unexpected error occurred while loading ads. |

| ### Public fields |
|---|---|
| `final int` | `@https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException.Type https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#type()` The `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException.Type` of the ad load exception. |

| ### Public methods |
|---|---|
| `static https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#createForAd(java.lang.Exception)(https://developer.android.com/reference/java/lang/Exception.html error)` Returns a new ad load exception of `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#TYPE_AD()`. |
| `static https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#createForAdGroup(java.lang.Exception,int)(https://developer.android.com/reference/java/lang/Exception.html error, int adGroupIndex)` Returns a new ad load exception of `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#TYPE_AD_GROUP()`. |
| `static https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#createForAllAds(java.lang.Exception)(https://developer.android.com/reference/java/lang/Exception.html error)` Returns a new ad load exception of `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#TYPE_ALL_ADS()`. |
| `static https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#createForUnexpected(java.lang.RuntimeException)(https://developer.android.com/reference/java/lang/RuntimeException.html error)` Returns a new ad load exception of `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#TYPE_UNEXPECTED()`. |
| `https://developer.android.com/reference/java/lang/RuntimeException.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#getRuntimeExceptionForUnexpected()()` Returns the `https://developer.android.com/reference/java/lang/RuntimeException.html` that caused the exception if its type is `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#TYPE_UNEXPECTED()`. |

### Inherited methods

From [java.lang.Throwable](https://developer.android.com/reference/java/lang/Throwable.html) `synchronized final void` `https://developer.android.com/reference/java/lang/Throwable.html#addSuppressed(java.lang.Throwable)(https://developer.android.com/reference/java/lang/Throwable.html exception)` `synchronized https://developer.android.com/reference/java/lang/Throwable.html` `https://developer.android.com/reference/java/lang/Throwable.html#fillInStackTrace()()` `synchronized https://developer.android.com/reference/java/lang/Throwable.html` `https://developer.android.com/reference/java/lang/Throwable.html#getCause()()` `https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/java/lang/Throwable.html#getLocalizedMessage()()` `https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/java/lang/Throwable.html#getMessage()()` `StackTraceElement[]` `https://developer.android.com/reference/java/lang/Throwable.html#getStackTrace()()` `synchronized final Throwable[]` `https://developer.android.com/reference/java/lang/Throwable.html#getSuppressed()()` `synchronized https://developer.android.com/reference/java/lang/Throwable.html` `https://developer.android.com/reference/java/lang/Throwable.html#initCause(java.lang.Throwable)(https://developer.android.com/reference/java/lang/Throwable.html cause)` `void` `https://developer.android.com/reference/java/lang/Throwable.html#printStackTrace()()` `void` `https://developer.android.com/reference/java/lang/Throwable.html#setStackTrace(java.lang.StackTraceElement[])(StackTraceElement[] stackTrace)` `https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/java/lang/Throwable.html#toString()()`

## Constants

### TYPE_AD

```
public static final int TYPE_AD = 0
```

Type for when an ad failed to load. The ad will be skipped.

### TYPE_AD_GROUP

```
public static final int TYPE_AD_GROUP = 1
```

Type for when an ad group failed to load. The ad group will be skipped.

### TYPE_ALL_ADS

```
public static final int TYPE_ALL_ADS = 2
```

Type for when all ad groups failed to load. All ads will be skipped.

### TYPE_UNEXPECTED

```
public static final int TYPE_UNEXPECTED = 3
```

Type for when an unexpected error occurred while loading ads. All ads will be skipped.

## Public fields

### type

```
@AdsMediaSource.AdLoadException.Type
public final int type
```

The `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException.Type` of the ad load exception.

## Public methods

### createForAd

```
public static AdsMediaSource.AdLoadException createForAd(Exception error)
```

Returns a new ad load exception of `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#TYPE_AD()`.

### createForAdGroup

```
public static AdsMediaSource.AdLoadException createForAdGroup(Exception error, int adGroupIndex)
```

Returns a new ad load exception of `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#TYPE_AD_GROUP()`.

### createForAllAds

```
public static AdsMediaSource.AdLoadException createForAllAds(Exception error)
```

Returns a new ad load exception of `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#TYPE_ALL_ADS()`.

### createForUnexpected

```
public static AdsMediaSource.AdLoadException createForUnexpected(RuntimeException error)
```

Returns a new ad load exception of `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#TYPE_UNEXPECTED()`.

### getRuntimeExceptionForUnexpected

```
public RuntimeException getRuntimeExceptionForUnexpected()
```

Returns the `https://developer.android.com/reference/java/lang/RuntimeException.html` that caused the exception if its type is `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource.AdLoadException#TYPE_UNEXPECTED()`.