A caller of the Sage SDK client isn't able to detect that a thrown error is an instance of one of the Sage SDK exception types (Intacct, Result, Response) even if the error is one of those types. The instanceof check will unexpectedly evaluate to false. See example code below.
const client = new SageIntacct.OnlineClient(clientConfig);
try {
await client.execute(readArInvoiceQuery);
} catch (err) { // Assume err is a ResponseException thrown in the xml2js.parseString callback
if (err instanceof SageIntacct.Exceptions.ResponseException) { // This will be false
console.log('got SageIntacct.Exceptions.ResponseException');
} else {
console.log('got unknown exception.');
}
}
I noticed this issue when a ResponseException was thrown here.
It seems that any error thrown in the xml2js.parseString callback here is "wrapped" as an unhandled exception. I verified that errors thrown outside the parseString callback but still in the AbstractResponse constructor are not "wrapped" as unhandled errors.
The JSON representation of the error propagated up to callers of the Sage SDK client looks like this:
{"code":"ERR_UNHANDLED_ERROR","context":{"errors":[ /* some error */]}}
The string representatio looks something like this:
Unhandled error. (ResponseException [Error]: Response control status failure - /* some details */
A caller of the Sage SDK client isn't able to detect that a thrown error is an instance of one of the Sage SDK exception types (Intacct, Result, Response) even if the error is one of those types. The
instanceofcheck will unexpectedly evaluate to false. See example code below.I noticed this issue when a ResponseException was thrown here.
It seems that any error thrown in the xml2js.parseString callback here is "wrapped" as an unhandled exception. I verified that errors thrown outside the
parseStringcallback but still in theAbstractResponseconstructor are not "wrapped" as unhandled errors.The JSON representation of the error propagated up to callers of the Sage SDK client looks like this:
The string representatio looks something like this: