Skip to content

iOS Error Codes

Overview

This document lists the error codes that the UjuAd iOS SDK may return and their meanings, helping developers quickly troubleshoot and resolve issues.

In the onLoadError and onAdError callbacks, developers receive a UjuException object and obtain error information via error.code and error.message.

iOS Error Codes Differ from Android

iOS uses the UjuErrorCode enum (grouped: 0 / 1-3 / 100-103 / 200-202 / ...), while Android uses the ErrorType enum (0 / 1000-2011). Do not confuse the error codes of the two platforms; refer to each platform's error code documentation separately.

UjuException Structure

swift
public struct UjuException: Error, CustomStringConvertible {
    public let code: Int                  // 错误码,对应 UjuErrorCode.rawValue
    public let message: String            // 错误信息
    public let underlyingError: Error?    // 底层错误(可选,用于调试)
    public var description: String { get } // "UjuException(code=X, message=Y)"
}

Log Output Recommendations

When printing errors, use error.description or String(describing: error). Do not use error.localizedDescription (which falls back to NSError's default description, such as "The operation couldn't be completed. (UjuAdCore.UjuException error 5.)").

UjuErrorCode Error Codes

The UjuErrorCode enum is defined by business group:

Init

Error CodeEnum NameMeaningPossible CauseSolution
0unknownUnknown errorUnknown causeContact technical support and provide logs
1initFailedInitialization failedIncorrect appId/appKey, network issues, configuration errorsCheck appId/appKey/region, check network
2initInvalidConfigInvalid initialization configurationUjuAdInitConfig.create parameters missing or malformedCheck that configuration parameters are complete and correct
3notInitializedSDK not initializedLoading ads before calling initialize/startEnsure two-phase initialization is completed first

Load

Error CodeEnum NameMeaningPossible CauseSolution
100loadFailedLoad failedAdapter exception, ad placement configuration errorCheck ad placement ID, retry later
101loadTimeoutLoad timeoutAd request timed outCheck network conditions, increase timeout or retry appropriately
102noFillNo fillADX had no bid this time, insufficient ad inventory, frequency cap reachedNormal business response; can fall back or retry later
103invalidPlacementInvalid ad placementplacementId is empty or does not existCheck that the ad placement ID is correct

Show

Error CodeEnum NameMeaningPossible CauseSolution
200showFailedShow failedDisplay process exceptionCheck display timing and container
201adNotReadyAd not readyCalled show before load successEnsure show is called after onLoadSuccess, check isReady()
202frequencyCappedFrequency cappedDisplay frequency limit reachedWait for frequency reset before displaying

Network

Error CodeEnum NameMeaningPossible CauseSolution
300networkErrorNetwork errorNo network connectionCheck network connection
301networkTimeoutNetwork timeoutNetwork request timed outCheck network conditions, retry later
302networkUnavailableNetwork unavailableNetwork completely unavailablePrompt user to check network

Parse

Error CodeEnum NameMeaningPossible CauseSolution
400parseErrorParse errorData format exceptionContact technical support
401encryptionErrorEncryption errorRSA/AES encryption failedCheck that rsaPublicKey is correct
402decryptionErrorDecryption errorServer data decryption failedCheck rsaPublicKey / contact technical support

Config

Error CodeEnum NameMeaningPossible CauseSolution
500configErrorConfiguration errorStrategy configuration exceptionContact technical support
501configVersionMismatchConfiguration version mismatchLocal cached config version inconsistent with serverClear cache and retry

Cache

Error CodeEnum NameMeaningPossible CauseSolution
600cacheErrorCache errorCache read/write exceptionContact technical support
601cacheIOErrorCache IO errorDisk read/write failureCheck disk space

Others

Error CodeEnum NameMeaningPossible CauseSolution
700crashReportFailedCrash report failedCrash information upload failedDoes not affect main flow; can be ignored
800adapterNotRegisteredAdapter not registeredCorresponding ADN adapter not registeredCheck registerAdapterFactory call
801adapterInitFailedAdapter initialization failedThird-party SDK initialization failedCheck third-party SDK configuration
802adapterUnsupportedFormatAdapter does not support this formatAdapter does not support current ad formatCheck ad placement and adapter compatibility

onLoadError vs onAdError

Load Failure vs Show Failure

  • onLoadError(error: UjuException): Ad load phase failure (1 parameter), common error codes 1/2/100/101/102/103/300/301
  • onAdError(error: UjuException): Ad show phase failure (1 parameter), common error codes 200/201/202

Both onLoadError and onAdError on iOS take 1 parameter (error), unlike Android (Android's onLoadError has 2 parameters including placementId).

Error Handling Example

swift
func onLoadError(error: UjuException) {
    switch error.code {
    case UjuErrorCode.noFill.rawValue:
        // ADX 无出价,正常业务响应,可降级到其他广告源
        print("无填充,稍后重试")
    case UjuErrorCode.networkError.rawValue, UjuErrorCode.networkTimeout.rawValue:
        // 网络问题,提示用户检查网络
        print("网络异常,请检查网络连接")
    case UjuErrorCode.adNotReady.rawValue:
        // 广告未就绪,需先调用 load()
        print("广告未就绪,请先加载")
    default:
        print("广告错误: \(error.description)")
    }
}

func onAdError(error: UjuException) {
    // 展示阶段失败
    print("展示失败: code=\(error.code), msg=\(error.message)")
}

Retry Mechanism Recommendations

  • For network errors (300/301/302) and load timeout (101), implement a reasonable retry mechanism
  • Set retry intervals and maximum retry counts to avoid infinite retries
  • Recommended retry interval of 3-5 seconds, maximum 3 retries
  • noFill (102) is not recommended for immediate retry; wait a longer interval before retrying

Common Troubleshooting Table

SymptomPossible Error CodeTroubleshooting Direction
SDK initialization failure1/2Check if appId/appKey/region is correct
Ad does not load100/102/103Check ad placement ID, network connection
Ad does not show201Confirm show is called after onLoadSuccess, check isReady()
No fill102Normal phenomenon, insufficient ad inventory, retry later
Network error300/301/302Check network connection
Encryption/decryption failure401/402Check if rsaPublicKey is correct

Contact Technical Support

If you encounter error issues that cannot be resolved, you can contact technical support via:

Providing the error code, error message, environment, and reproduction steps will help technical support locate the issue faster.