diff --git a/apps/desktop/src/components/SendFlow/utils.tsx b/apps/desktop/src/components/SendFlow/utils.tsx
index e14b2142f2..5cb1eff3b3 100644
--- a/apps/desktop/src/components/SendFlow/utils.tsx
+++ b/apps/desktop/src/components/SendFlow/utils.tsx
@@ -157,17 +157,22 @@ export const useSignPageHelpers = (
).catch(() => setEstimationFailed(true));
const onSign = async (tezosToolkit: TezosToolkit) =>
- handleAsyncAction(async () => {
- const operation = await executeOperations(
- { ...operations, estimates: form.watch("executeParams") },
- tezosToolkit
- );
- if (mode === "batch") {
- clearBatch(operations.sender);
+ handleAsyncAction(
+ async () => {
+ const operation = await executeOperations(
+ { ...operations, estimates: form.watch("executeParams") },
+ tezosToolkit
+ );
+ if (mode === "batch") {
+ clearBatch(operations.sender);
+ }
+ await openWith();
+ return operation;
+ },
+ {
+ description: "Something went wrong, please try again.",
}
- await openWith();
- return operation;
- });
+ );
return {
fee: totalFee(form.watch("executeParams")),
diff --git a/apps/web/src/components/Menu/ErrorLogsMenu/ErrorLogsMenu.tsx b/apps/web/src/components/Menu/ErrorLogsMenu/ErrorLogsMenu.tsx
index 9e723cfa54..9faf330c18 100644
--- a/apps/web/src/components/Menu/ErrorLogsMenu/ErrorLogsMenu.tsx
+++ b/apps/web/src/components/Menu/ErrorLogsMenu/ErrorLogsMenu.tsx
@@ -58,6 +58,9 @@ export const ErrorLogsMenu = () => {
{errorLog.timestamp}
+
+ {errorLog.technicalDetails}
+
diff --git a/apps/web/src/components/SendFlow/utils.tsx b/apps/web/src/components/SendFlow/utils.tsx
index 2b1c3e3a3c..b277be4a1b 100644
--- a/apps/web/src/components/SendFlow/utils.tsx
+++ b/apps/web/src/components/SendFlow/utils.tsx
@@ -123,14 +123,18 @@ export const useSignPageHelpers = (
).catch(() => setEstimationFailed(true));
const onSign = async (tezosToolkit: TezosToolkit) =>
- handleAsyncAction(async () => {
- const operation = await executeOperations(
- { ...operations, estimates: form.watch("executeParams") },
- tezosToolkit
- );
- await openWith();
- return operation;
- });
+ handleAsyncAction(
+ async () => {
+ const operation = await executeOperations(
+ { ...operations, estimates: form.watch("executeParams") },
+ tezosToolkit
+ );
+ await openWith();
+ return operation;
+ },
+ // Here we should show a generic error message, keeping the original error for errors list
+ { description: "Something went wrong, please try again." }
+ );
return {
fee: totalFee(form.watch("executeParams")),
diff --git a/packages/core/src/ErrorContext.ts b/packages/core/src/ErrorContext.ts
index 8240de8731..14b6104e3c 100644
--- a/packages/core/src/ErrorContext.ts
+++ b/packages/core/src/ErrorContext.ts
@@ -1,25 +1,37 @@
+import { handleTezError } from "./estimate";
+
export type ErrorContext = {
timestamp: string;
description: string;
stacktrace: string;
+ technicalDetails: string;
};
export const getErrorContext = (error: any): ErrorContext => {
- let description = "Something went wrong";
- if (typeof error === "object" && "message" in error) {
- description = error.message;
- } else if (typeof error === "string") {
- description = error;
- }
+ console.log({ error });
+ let description =
+ "Something went wrong. Please try again or contact support if the issue persists.";
+ let technicalDetails;
let stacktrace = "";
if (typeof error === "object" && "stack" in error) {
stacktrace = error.stack;
}
+ if (error instanceof Error) {
+ description = handleTezError(error) ?? description;
+ }
+
+ if (typeof error === "object" && "message" in error) {
+ technicalDetails = error.message;
+ } else if (typeof error === "string") {
+ technicalDetails = error;
+ }
+
return {
timestamp: new Date().toISOString(),
description,
stacktrace,
+ technicalDetails,
};
};
diff --git a/packages/core/src/estimate.ts b/packages/core/src/estimate.ts
index abc98a1407..b21208958e 100644
--- a/packages/core/src/estimate.ts
+++ b/packages/core/src/estimate.ts
@@ -41,9 +41,7 @@ export const estimate = async (
if (!isRevealed) {
throw new Error(`Signer address is not revealed on the ${network.name}.`);
}
- if (err instanceof Error) {
- err.message = handleTezError(err);
- }
+
throw err;
}
};
@@ -59,13 +57,14 @@ const estimateToEstimation = (estimate: Estimate): Estimation => ({
});
// Converts a known L1 error message to a more user-friendly one
-export const handleTezError = (err: Error): string => {
+export const handleTezError = (err: Error): string | undefined => {
if (err.message.includes("subtraction_underflow")) {
return "Insufficient balance, please make sure you have enough funds.";
} else if (err.message.includes("contract.non_existing_contract")) {
return "Contract does not exist, please check if the correct network is selected.";
} else if (err.message.includes("staking_to_delegate_that_refuses_external_staking")) {
return "The baker you are trying to stake to does not accept external staking.";
+ } else if (err.message.includes("empty_implicit_delegated_contract")) {
+ return "Emptying an implicit delegated account is not allowed.";
}
- return err.message;
};