What is the best way to catch exceptions in the response payload for API calls made to the Yodlee REST Aggregation API?
Historically speaking I've seen {'Error' => [{'errorDetail' => 'some error message'}]}
, but I've also seen {'errorOccured' => true, 'exceptionType' => 'some documented exception type', 'referenceCode' => ''}
.
The documentation suggests I can expect exceptionType, but I'd like to be sure. The API call I'm currently most concerned with is /login.
Here are types of error code format which you can expect-
JSON exception format 1: { "errorOccurred": "true", "exceptionType": "com.yodlee.core.SiteNotFoundException", "referenceCode": "_afe4ae60-68fe-4443-a721-d97a192e9455", "message": "Argument value not found: 164413432" }
JSON exception format 2 (Same as format 1, but "message" attribute is missing so considered as additional): { "errorOccurred": "true", "exceptionType": "Exception Occurred", "referenceCode": "_5c4d1347-cb4a-4404-809b-57dbfabcf1db" }
JSON exception format 3: { "Error": [ { "errorDetail": "No session ID found " } ] }
JSON exception format 4 (Same as format 3, but "errorDetail" attribute is missing so considered as additional): { "Error": [ null ] }
JSON exception format 5: { "errorDetail": "Token authentication failed for cobrand/user Invalid cobrand conversation credentials" }
This will cover almost all the scenarios.