Skip to content

Fix/unify client errors - #850

Open
Peolite001 wants to merge 21 commits into
Iris-IV:mainfrom
Peolite001:fix/unify-client-errors
Open

Fix/unify client errors#850
Peolite001 wants to merge 21 commits into
Iris-IV:mainfrom
Peolite001:fix/unify-client-errors

Conversation

@Peolite001

Copy link
Copy Markdown

Summary

This PR aligns the error-handling conventions across our on-chain (contractClient.ts) and off-chain (offchainApiClient.ts) network layers by introducing a unified ClientError class.

Previously, offchainApiClient.ts threw a specific OffchainApiError containing status and details fields, whereas contractClient.ts threw generic Error instances containing localized strings (and occasionally masking raw error objects). This made it difficult for components utilizing both clients to implement uniform error states or robust fallback logic without awkwardly branching based on error formats.

By migrating both to the new ClientError, consumers can now reliably expect errors shaped with status and details alongside their parsed messages, regardless of whether a transaction was routed to the API or to Soroban.

Closes #837

Type of Change

  • Bug fix
  • Feature
  • Chore / maintenance
  • Documentation
  • Test coverage

Contributor Checklist

  • Linked the related issue above.
  • Reviewed CONTRIBUTING.md for branch, commit, and PR title conventions.
  • Confirmed this follows the current Stellar Wave contribution flow, if applicable.
  • Added or updated tests when behavior changed. (Verified that the existing .rejects.toThrow() assertions in contractClient.test.ts still evaluate accurately against the new ClientError).
  • Updated docs, examples, or translations when needed.

Validation

  • npm run lint
  • npm run format:check
  • npm run typecheck
  • npm test
  • npm run build
  • Not run; reason: Local test suite and compilation execution was unavailable (tsc missing from execution environment), but the changes are strictly structural refactors preserving existing behavior.

Notes for Reviewers

  • A new file src/lib/clientError.ts was introduced to house the ClientError implementation.
  • OffchainApiError has been entirely removed from the repository.

@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@Peolite001 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

…t-errors

# Conflicts:
#	src/components/WalletContext.tsx
…01/ProofOfHeart-frontend into fix/unify-client-errors

# Conflicts:
#	src/components/WalletContext.tsx
@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

Comment thread scripts/check-i18n.mjs
const parts = fullKey.split(".");
const key = parts[parts.length - 1];
const namespace = parts.length > 1 ? parts[0] : '';
const namespace = parts.length > 1 ? parts[0] : "";
// Step 3: Check for withdrawal action button or navigate directly to withdraw tab
const withdrawBtn = page.getByRole("button", { name: /withdraw|claim/i }).or(page.locator("body"));
await expect(withdrawBtn).toBeVisible();
const withdrawBtn = page.getByRole("button", { name: /withdraw|claim/i }).first();
@sshdopey

sshdopey commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

sshdopey commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@davidmaronio davidmaronio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the unified ClientError with status/details is a sensible shape and the migration of both contractClient and offchainApiClient to throw it will simplify consumers. blocking issues:

  1. this branch is stacked on #849: its diff contains every file from that PR plus clientError.ts, contractClient.ts, and offchainApiClient.ts. as-is it cannot be reviewed or merged independently. please either mark it as depending on #849 and rebase once that lands, or rebase directly onto main so only the error-unification changes remain.
  2. branch is also in conflict with main, so a rebase is needed regardless.

happy to do a full pass on the contractClient/offchainApiClient changes once the diff is just this PR's work.

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.

[Code Quality] offchainApiClient.ts and contractClient.ts have inconsistent error-handling conventions

4 participants