# AdError

# AdError


```
public class AdError
```

<br />

Known direct subclasses [AdInspectorError](https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdInspectorError), [LoadAdError](https://developers.google.com/admob/android/reference/com/google/android/gms/ads/LoadAdError)

|---|---|
| `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdInspectorError` | Error information about why the ad inspector failed. |
| `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/LoadAdError` | Error information about why an ad load operation failed. |

*** ** * ** ***

Error information about why an ad operation failed.

## Summary

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError#UNDEFINED_DOMAIN() = "undefined"` The undefined error domain. |

| ### Public fields |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError#cause()` |
| `final int` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError#code()` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError#domain()` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError#message()` |

| ### Public constructors |
|---|
| `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError#AdError(int,java.lang.String,java.lang.String)(int code, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html message, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html domain)` Creates an `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError`. |
| `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError#AdError(int,java.lang.String,java.lang.String,com.google.android.gms.ads.AdError)( int code, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html message, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html domain, @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError cause )` Creates an `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError` with an underlying `cause`. |

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable.html https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError#getCause()()` Gets the cause of this error or `null` if the cause is nonexistent or unknown. |
| `int` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError#getCode()()` Gets the error's code. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError#getDomain()()` Gets the domain of the error. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError#getMessage()()` Gets the message describing the error. |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError#toString()()` Returns a log friendly string version of this object. |

## Constants

### UNDEFINED_DOMAIN

```
public static final String UNDEFINED_DOMAIN = "undefined"
```

The undefined error domain.

The Google Mobile Ads SDK returns this domain for `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError#getDomain()` when converting error information from legacy mediation adapter callbacks like onFailure to an `AdError`.

## Public fields

### cause

```
public final @Nullable AdError cause
```

### code

```
public final int code
```

### domain

```
public final @NonNull String domain
```

### message

```
public final @NonNull String message
```

## Public constructors

### AdError

```
public AdError(int code, @NonNull String message, @NonNull String domain)
```

Creates an `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError`.

| Parameters |
|---|---|
| `int code` | the error code. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html message` | a message detailing the error. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html domain` | the error domain. |

### AdError

```
public AdError(
    int code,
    @NonNull String message,
    @NonNull String domain,
    @Nullable AdError cause
)
```

Creates an `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError` with an underlying `cause`.

| Parameters |
|---|---|
| `int code` | the error code. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html message` | a message detailing the error. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html domain` | the error domain. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable.html https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdError cause` | the cause of this error. |

## Public methods

### getCause

```
public @Nullable AdError getCause()
```

Gets the cause of this error or `null` if the cause is nonexistent or unknown.

### getCode

```
public int getCode()
```

Gets the error's code.

### getDomain

```
public @NonNull String getDomain()
```

Gets the domain of the error.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/MobileAds#ERROR_DOMAIN()` for Google Mobile Ads SDK errors, or a domain defined by mediation networks for mediation errors. |

### getMessage

```
public @NonNull String getMessage()
```

Gets the message describing the error.

### toString

```
public String toString()
```

Returns a log friendly string version of this object.