crystalbit/node-sberbank-acquiring

global error thrown

Closed this issue · 1 comments

global error occured in get method

global error thrown, even this is async function and should return resolve if order not found?

await acquiring.get(undefined, orderNumber);
JoCat commented

Since the query returns a non-zero error code, it is treated as an error in any case.

You can intercept the error in the request with try/catch and, in case of an error with an order not found, use resolve
for example:

try {
  await acquiring.get(undefined, orderNumber);
} catch (error) {
  if (error.sberErrorCode == 6 /* or === '6' */) {
    return 'Order not found';
  }
  console.error('Error is caught:', error);
}