Error Codes
The SDK returns errors as BidMachineError (Swift) / BMError (Obj-C), a subclass of NSError. Two things are public:
error.code— the numeric category (Int, fromNSError).error.message— a human-readable description (String).
Switch on error.code against the numbers below to handle specific failures.
note
Named code constants are not part of the public API. The backing Code enum is internal, and there are no BMErrorCode* Obj-C constants — only the raw error.code number and error.message string are exposed. Switch on the number.
Code Reference
The internal case names are shown for orientation only — they are not callable from app code.
| Code | Internal name | Description |
|---|---|---|
100 | connection | Can't connect to server. |
101 | badContent | Response content is malformed or cannot be parsed. |
102 | timeout | Timeout reached. |
103 | noFill | No fill. |
104 | adNotReady | Ad is not ready to be shown. |
105 | alreadyLoading | A load is already in progress. |
106 | destroyed | Ad was destroyed. |
107 | expired | Ad was expired. |
108 | internal | Unknown internal error. |
109 | server | Server failed to fulfill an apparently valid request. |
110 | badRequest | Request contains bad syntax or cannot be fulfilled. |
200 | headerBidding | Adapter / header-bidding network error. |
Handling Errors
- Swift
- Objective-C
func didFailToLoadAd(adInfo: AdInfo?, error: BidMachineError) {
switch error.code {
case 103: print("No fill")
case 102: print("Timed out")
default: print("Load failed (\(error.code)): \(error.message)")
}
}
- (void)didFailToLoadAdWithAdInfo:(BMAdInfo *)adInfo error:(BMError *)error {
switch (error.code) {
case 103: NSLog(@"No fill"); break;
case 102: NSLog(@"Timed out"); break;
default: NSLog(@"Load failed (%ld): %@", (long)error.code, error.message); break;
}
}
note
iOS does not expose a public log formatter or a cause property. Read error.message directly; an underlying NSError may be attached via NSUnderlyingErrorKey.