@alviere/core 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/entities/constants/error-codes.d.ts +1 -0
- package/dist/entities/constants/error-codes.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -10
- package/dist/index.mjs.map +1 -1
- package/dist/infrastructure/gateways/alcore-base.gateway.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -658,7 +658,8 @@ const AlcoreErrorCodes = {
|
|
|
658
658
|
UNDERLYING_API_ERROR: "115000",
|
|
659
659
|
ACCOUNT_STATUS_NOT_ACTIVE: "115001",
|
|
660
660
|
ACCOUNT_CHILD_FORBIDDEN: "320129",
|
|
661
|
-
PARENT_ACCOUNT_NOT_ALLOWED: "320104"
|
|
661
|
+
PARENT_ACCOUNT_NOT_ALLOWED: "320104",
|
|
662
|
+
BANK_ACCOUNT_PRIMARY_REQUIRES_ACTIVE_STATUS: "340028"
|
|
662
663
|
// Add more error codes as you discover them from the API
|
|
663
664
|
};
|
|
664
665
|
const AlcoreErrorMessages = {
|
|
@@ -683,7 +684,8 @@ const AlcoreErrorMessages = {
|
|
|
683
684
|
[AlcoreErrorCodes.UNDERLYING_API_ERROR]: "Underlying API Error. ",
|
|
684
685
|
[AlcoreErrorCodes.ACCOUNT_STATUS_NOT_ACTIVE]: "Account status not active. Please check your request and try again.",
|
|
685
686
|
[AlcoreErrorCodes.ACCOUNT_CHILD_FORBIDDEN]: "Used Account can't be used to create a child account.",
|
|
686
|
-
[AlcoreErrorCodes.PARENT_ACCOUNT_NOT_ALLOWED]: "Parent account not allowed. Please check your request and try again."
|
|
687
|
+
[AlcoreErrorCodes.PARENT_ACCOUNT_NOT_ALLOWED]: "Parent account not allowed. Please check your request and try again.",
|
|
688
|
+
[AlcoreErrorCodes.BANK_ACCOUNT_PRIMARY_REQUIRES_ACTIVE_STATUS]: "Only ACTIVE bank accounts can be set as primary."
|
|
687
689
|
};
|
|
688
690
|
function getErrorMessage(errorCode) {
|
|
689
691
|
return AlcoreErrorMessages[errorCode] || "An unexpected error occurred. Please try again.";
|
|
@@ -771,14 +773,10 @@ class AlcoreBase {
|
|
|
771
773
|
if (error.p) {
|
|
772
774
|
error = await this.decrypt(error);
|
|
773
775
|
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
);
|
|
777
|
-
throw new AlcoreApiError(
|
|
778
|
-
response.status === 500 ? AlcoreErrorCodes.UNDERLYING_API_ERROR : error.error_code,
|
|
779
|
-
AlcoreErrorMessages[error.error_code],
|
|
780
|
-
response.status
|
|
781
|
-
);
|
|
776
|
+
const errorCode = response.status === 500 ? AlcoreErrorCodes.UNDERLYING_API_ERROR : error.error_code;
|
|
777
|
+
const errorDescription = error.error_description || getErrorMessage(errorCode);
|
|
778
|
+
this.logger.debug(`❌ API Error - Code: ${errorCode}, Description: ${errorDescription}`);
|
|
779
|
+
throw new AlcoreApiError(errorCode, errorDescription, response.status);
|
|
782
780
|
}
|
|
783
781
|
return response;
|
|
784
782
|
} catch (fetchError) {
|