Error Handling
In case where an ad fails to load or display, BlueStack provides the following exceptions in error callback.
| Exception | Error Code | Message | Meaning |
|---|---|---|---|
| WrongPlacementIdError | WRONG_PLACEMENT_ERROR = 0 | Wrong placement | Invalid placement ID configured |
| InternetError | NO_INTERNET_ERROR = 1 | No Internet | No internet connection available |
| SDKUninitializedError | SDK_UNINITIALIZED_ERROR = 2 | BlueStack is not initialized | SDK must be initialized first |
| RequestCappedError | CAPPED_REQUEST_ERROR = 3 | Your request has been capped | Request limit reached. Check placement capping settings |
| LockedPlacementError | LOCKED_PLACEMENT_ERROR = 4 | This placement is locked by an other factory | Another factory is loading an ad for this placement |
| BusyFactoryError | BUSY_FACTORY_ERROR = 5 | Your factory is busy | Factory is processing another request |
| NoAdError | NO_AD_ERROR = 7 | No Ad found | No ad available to deliver |
| InterstitialCoolDownError | INTERSTITIAL_COOLDOWN_ERROR = 8 | Interstitial cooldown active | Interstitial ad is in cooldown period. Wait before showing another |
| AlreadyShownInterstitialError | INTERSTITIAL_ALREADY_SHOWN_ERROR = 9 | Other Interstitial is shown | Only one interstitial can be shown at a time |
| TimeOutError | TIME_OUT_ERROR = 10 | no ad to deliver before time out | Ad request timed out before response |
| AdapterNotFoundError | ADAPTER_NOT_FOUND_ERROR = 11 | No adapter found | Mediation adapter not found. See Mediation Partners |
| BlockedByGDPRError | BLOCKED_BY_GDPR = 12 | Request blocked by GDPR | Ad request blocked due to GDPR consent requirements |
| AdExpiredError | AD_EXPIRED = 13 | Ad has expired | Ad exceeded display time limit (typically for interstitials) |
| NoAdapterFoundForPlacementIdError | NO_ADAPTER_FOUND_FOR_PLACEMENT_ID = 14 | No adapter found for placementId | No mediation adapter configured for the specific placement ID |
Handle Error : To determine which exception was triggered, cast the exception to AdError in the fail callback and use getErrorCode() to retrieve the error code. You can also get the exception message by calling getMessage(). In the example below, we use onAdFailToLoad, but this logic can be applied to any fail callback, such as onAdFailToRefresh, onAdFailedToDisplay, infeedDidFail and nativeObjectDidFail etc.
- Java
- Kotlin
@Override
public void onAdFailedToLoad(Exception e) {
AdError adError = (AdError)e;
switch (adError.getErrorCode())
{
case AdError.BUSY_FACTORY_ERROR :
case AdError.INTERSTITIAL_ALREADY_SHOWN_ERROR :
.
.
.
}
Log.e(TAG, "Banner did fail : " + adError.getMessage()+" error code "+adError.getErrorCode());
}
override fun onAdFailedToLoad(e: Exception) {
val adError = e as AdError
when (adError.errorCode){
AdError.BUSY_FACTORY_ERROR -> {...}
AdError.INTERSTITIAL_ALREADY_SHOWN_ERROR -> {...}
.
.
.
}
Log.e(TAG, "Banner did fail : ${adError.message} error code ${adError.errorCode}")
}