Handling iOS SDK Error

This guide will help you handle and troubleshoot errors that may occur while using Dapi iOS SDK.

When using Dapi iOS SDK, any errors that occur will be passed to you as an Error object in swift and NSError. This native object contains more information than is specified for Dapi.

ParameterTypeDescription
dapiErrorTypeStringError type.
dapiErrorMessageStringError message.
dapiOperationIDStringUnique ID generated by Dapi to identify a specific operation.
coolDownPeriodDAPICoolDownPeriodBeneficiary cool down period information (unit, value)
let autoFLow = DAPIAutoFlowVC(bankConnection: //connection,
                              beneficiary: //Beneficiary,
                              transferType: .normal)
autoFLow.transferDidFail = { error in
    print(error.dapiErrorMessage)
    print(error.dapiErrorType)
    print(error.dapiOperationID)
    print(error.dapiStatusCode)
    print(error.coolDownPeriod)
}
self.present(autoFLow, animated: true)
DAPIAutoFlowVC *autoflow = [[DAPIAutoFlowVC alloc] initWithBankConnection://selectedConnection
                                                                  account:nil
                                                          wireBeneficiary: nil
                                                              beneficiary://[self beneficiary]
                                                             transferType:DAPITransferTypeNormal
                                                                   amount:0
                                                                   remark:@"remark"];
[autoflow setTransferDidFail:^(NSError  * _Nonnull error ) {
    NSLog(@"[DAPI] error:  %@",error.dapiOperationID);
    NSLog(@"[DAPI] type:  %@",error.dapiErrorType);
    NSLog(@"[DAPI] code:  %@",error.dapiStatusCode);
    NSLog(@"[DAPI] message:  %@",error.dapiErrorMessage);
    NSLog(@"[DAPI] dictionaryRepresentation :  %@",error.dictionaryRepresentation);
    NSDictionary *coolDownPeriod = [error.dictionaryRepresentation objectForKey:@"coolDownPeriod"];
    NSNumber *value = [coolDownPeriod objectForKey:@"value"];
    NSString *unit = [coolDownPeriod objectForKey:@"unit"];
    
}];
[autoflow setAutoFlowDelegate:self];
[self presentViewController:autoflow animated:YES completion:nil];

Beneficiary Cool Down

Some banks do not allow immediate transfers to a newly added beneficiary. Beneficiary Cooldown time shows how long the user needs to wait before they can make a transfer to a newly added beneficiary.

You can know the potential cooldown value ahead of time by using Get Account Metadata endpoint. The value varies from bank to bank.

If you encounter a BENEFICIARY_COOL_DOWN_PERIOD error, you will receive an error object with the error type set to BENEFICIARY_COOL_DOWN_PERIOD and the object will contain information about the beneficiary cooldown period coolDownPeriod, including the unit and value, which you can access to handle the error appropriately.

autoFLow.transferDidFail = { error in
    print(error.dapiErrorType)
    print(error.coolDownPeriod?.unit)
    print(error.coolDownPeriod?.value)
}
[autoflow setTransferDidFail:^(NSError  * _Nonnull error ) {
    NSLog(@"[DAPI] type:  %@",error.dapiErrorType);
    NSDictionary *coolDownPeriod = [error.dictionaryRepresentation objectForKey:@"coolDownPeriod"];
    NSNumber *value = [coolDownPeriod objectForKey:@"value"];
    NSString *unit = [coolDownPeriod objectForKey:@"unit"];
}];

If the user attempts to retry the request before the beneficiary cooldown period is complete, the error.type will still be BENEFICIARY_COOL_DOWN_PERIOD. However, in this case, the error.coolDownPeriod value will be null.