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 | You have set a wrong placement |
InternetError | NO_INTERNET_ERROR = 1 | No Internet | There is no internet connection at the moment |
SDKUninitializedError | SDK_UNINITIALIZED_ERROR = 2 | BlueStack is not initialized | You need to initialize the SDK first |
RequestCappedError | CAPPED_REQUEST_ERROR = 3 | Your request has been capped | Your request is capped, If you are in doubt, check your capping value related to the placement |
LockedPlacementError | LOCKED_PLACEMENT_ERROR = 4 | This placement is locked by an other factory | An other factory has loaded an ad using this placement, and its no yet displayed |
BusyFactoryError | BUSY_FACTORY_ERROR = 5 | Your factory is busy | Your factory is busy by an other request at the moment |
NoAdError | NO_AD_ERROR = 7 | No Ad found | Therese no ad to dilver at the moment |
AlreadyShownInterstitialError | INTERSTITIAL_ALREADY_SHOWN_ERROR = 9 | Other Interstitial is shown | We tolerate only one interstitial to be shown at time |
TimeOutError | TIME_OUT_ERROR = 10 | no ad to deliver before time out | Therese no ad to deliver before the specified time out |
AdapterNotFoundError | ADAPTER_NOT_FOUND_ERROR = 11 | SDK didn't able to find the mediation adapter for the ad network. Please check Our Mediation Partners section |
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}")
}