Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • path: intl-whitelabel-app/workspaces/frontend/src/utils/errors/index.ts

  • This method will be created to validate if the error is an RBI error, using the class RBIError2 which will renamed to RBIError in the future;.

Expand
titleisRBIError details
Code Block
languagetypescript
/**
 * Checks if the provided error code is an RBI error.
 *
 * @param {anyIRbiError} errorCodeRBIerror - The error code to be evaluated. Can be of any type.
 * @returns {boolean} - Returns true if the error code is considered an RBI error,
 *                      otherwise returns false.
 */
export const isRBIError = (errorCodeRBIerror: anyIRbiError): boolean => RbiError2.isRbiErrorPayload(errorCodeRBI)return !!error?.rbiErrorCode && !!error?.rbiErrorDomain;
extractRBIErrorCodes
  • path: intl-whitelabel-app/workspaces/frontend/src/utils/errors/index.ts

  • As the error is DOMAIN.SEVERITY.CODE.ERROR, for the translation, it will be necessary to create a method to split the error and get the translation.

  • For example:

    • If the error is: PAYMENT.2.102.001, the split will return the array with:

      • PAYMENT.2.102.001

      • PAYMENT.2.102

      • PAYMENT.2

      • PAYMENT

    • This array will be processed for the method getRBIErrorTranslation, which will be discussed in the below topic.

      • OBS.: This method needs to add in the return a function .reverse() to translation correct because normally the .split() will return an array: PAYMENT, PAYMENT.2, PAYMENT.2.102, PAYMENT.2.102.001, so the reverse is necessary to get the translation of the most detailed (PAYMENT.2.102.001) error to the least detailed (PAYMENT).

...