Skip to content

Commit

Permalink
fix: better errors text for WalletConnect
Browse files Browse the repository at this point in the history
  • Loading branch information
dianasavvatina committed Jan 3, 2025
1 parent 188d44e commit 3933801
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions packages/utils/src/ErrorContext.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ describe("handleTezError", () => {
expect(res).toBe("The delegate is unchanged. Delegation to this address is already done.");
});

it("returns undefined for unknown errors", () => {
it("returns default text for unknown errors", () => {
const err = new Error("unknown error");
expect(handleTezError(err)).toBeUndefined();
expect(handleTezError(err)).toBe(
"Tezos blockchain rejected the transaction: unknown error. Please try again or contact support if the issue persists."
);
});
});
6 changes: 5 additions & 1 deletion packages/utils/src/ErrorContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export const handleTezError = (err: Error): string | undefined => {
return "Emptying an implicit delegated account is not allowed. End delegation before trying again.";
} else if (err.message.includes("delegate.unchanged")) {
return "The delegate is unchanged. Delegation to this address is already done.";
} else if (err.message.includes("contract.manager.unregistered_delegate")) {
return "The provided delegate address is not registered as a delegate. Verify the delegate address and ensure it is active.";
}
};

Expand All @@ -59,7 +61,9 @@ export const getErrorContext = (error: any): ErrorContext => {
description = error.message;
technicalDetails = "";
} else if (error instanceof Error) {
description = handleTezError(error) ?? description;
description =
handleTezError(error) ||
`Tezos blockchain rejected the transaction: ${error.message}. Please try again or contact support if the issue persists.`;
}

return {
Expand Down

0 comments on commit 3933801

Please sign in to comment.