Handling Approval Errors
You should always check that any approval API call was successful before using the results.
-
For calls to NSOA.wsapi.submit(submitRequest), NSOA.wsapi.approve(approveRequest), NSOA.wsapi.reject(rejectRequest), and NSOA.wsapi.unapprove(unapproveRequest), you should check that a result was returned and did not have any errors.
This is a two-step process:
-
First, check that you have an array of responses.
if (!result || !result[0])
-
If OK, then check if you have an errors property and you have at least one error.
else if (result[0].errors !== null && result[0].errors.lenth > 0)
The following example checks for errors when using the NSOA.wsapi.approve(approveRequest) function:
// example assuming requests have already been defined
var results = NSOA.wsapi.approve(requests);
// Check for errors
if (!result || !result[0]) {
// An unexpected error has occurred!
} else if (result[0].errors !== null && result[0].errors.length > 0) {
// There are errors to handle!
} else {
// Process the response as expected
}
The errors property is an array of oaError objects.
See Code Samples for more examples.