Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/sdk/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ export function parseAPIError(response: unknown, fallbackStatus?: number): Vorte
if (errorMessage === "pixDestination is required for offramp to BRL") {
return new MissingBrlOfframpParametersError();
}
if (errorMessage === "Invalid pixKey or receiverTaxId") {
if (errorMessage === "Invalid pixKey or receiverTaxId.") {
return new InvalidPixKeyError();
}
if (errorMessage === "Parameter destinationAddress is required for this onramp") {
Expand Down
8 changes: 8 additions & 0 deletions packages/sdk/test/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
MoneriumReauthenticationRequiredError,
BrlKycStatusError,
MissingDomesticOfframpParametersError,
InvalidPixKeyError,
MissingBrlOfframpParametersError,
MissingBrlParametersError,
MykoboKycRequiredError,
Expand Down Expand Up @@ -103,6 +104,13 @@ describe("parseAPIError", () => {
expect(error.status).toBe(400);
});

test("maps the API's invalid pixKey message, trailing period included", () => {
const error = parseAPIError({ code: 400, message: "Invalid pixKey or receiverTaxId." });

expect(error).toBeInstanceOf(InvalidPixKeyError);
expect(error.status).toBe(400);
});

test("does not map the retired legacy BRL messages to the named errors", () => {
const onramp = parseAPIError({ code: 400, message: "Parameters destinationAddress and taxId are required for onramp" });
const offramp = parseAPIError({
Expand Down
Loading