Error Handling

While working with the SDK, you can receive an NSError object in case of failure:

  • Upon initialization;
  • When requesting an ad;
  • When loading an ad.

This NSError has a “domain” property that can be queried as follows:

if ([error.domain isEqualToString:@"DIOErrorDomain"]) {
    // Error specific to SDK
} else if ([error.domain isEqualToString:@"NSURLErrorDomain"]) {
    // Error specific to network
}

An error code can be obtained via:

error.code

If the domain of the NSError is “DIOErrorDomain”, the following enum is used:

typedef NS_ENUM(NSInteger, DIOErrorCode) {
    kDIOErrorMisc = 0,
    kDIOErrorNoDataSectionInResponse = 1,
    kDIOErrorNoPlacementsSectionInResponse = 2,
    kDIOErrorUnknownPlacementType = 3,
    kDIOErrorLoadingProviderMoreThanOnce = 4,
    kDIOErrorNoFill = 5,
    kDIOErrorNoAds = 6,
    kDIOErrorNoAd = 7,
    kDIOErrorAdUnavailable = 8,
    kDIOErrorParsing = 9
;

A text message can be obtained from the NSError via:

error.localizedDescription

Still have Questions?

Contact Us