Skip to content

feat: improve error messages for failed agent operations#78

Open
JerryIdoko wants to merge 1 commit into
Stellar-Tools:mainfrom
JerryIdoko:feat/improve-error-messages
Open

feat: improve error messages for failed agent operations#78
JerryIdoko wants to merge 1 commit into
Stellar-Tools:mainfrom
JerryIdoko:feat/improve-error-messages

Conversation

@JerryIdoko

Copy link
Copy Markdown

This PR addresses Issue #3 by introducing a centralized error decoder for Stellar and Soroban operations.

Key Changes:

  • Created \utils/errorDecoder.ts\ to translate Stellar/Horizon result codes and Soroban errors into human-readable messages.
  • Integrated the decoder into \lib/contract.ts, \lib/dex.ts, and \�gent.ts.
  • Added unit tests for the error decoder in \ ests/unit/utils/errorDecoder.test.ts.

Why:

Users previously received generic error messages like 'Transaction failed with status: 400'. Now, they will see descriptive messages such as 'Account has insufficient funds for this operation' or 'Missing trustline for asset', significantly improving the developer experience.

Resolves #3

This change introduces a centralized error decoder that translates Stellar and Soroban error codes into human-readable messages. It improves the UX by providing clearer feedback when transactions fail due to insufficient funds, missing trustlines, or slippage.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 6 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="lib/contract.ts">

<violation number="1" location="lib/contract.ts:157">
P2: Rewrapping every failure here discards the original error object, so callers lose the underlying type, stack, and SDK-specific fields.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread lib/contract.ts
throw error;
const decodedError = decodeStellarError(error);
console.error(`Error in contract interaction (${functName}):`, decodedError);
throw new Error(`Contract interaction failed: ${decodedError}`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Rewrapping every failure here discards the original error object, so callers lose the underlying type, stack, and SDK-specific fields.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At lib/contract.ts, line 157:

<comment>Rewrapping every failure here discards the original error object, so callers lose the underlying type, stack, and SDK-specific fields.</comment>

<file context>
@@ -149,9 +152,9 @@ import {
-      throw error;
+      const decodedError = decodeStellarError(error);
+      console.error(`Error in contract interaction (${functName}):`, decodedError);
+      throw new Error(`Contract interaction failed: ${decodedError}`);
     }
   };
</file context>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Error Messages for Failed Agent Operations

1 participant