Skip to content

feat: normalize API error messaging across pages (#469)#716

Merged
AnnabelJoe merged 2 commits into
AnnabelJoe:mainfrom
jaydenkalu:issues/469-normalize-api-error-messaging
Jul 3, 2026
Merged

feat: normalize API error messaging across pages (#469)#716
AnnabelJoe merged 2 commits into
AnnabelJoe:mainfrom
jaydenkalu:issues/469-normalize-api-error-messaging

Conversation

@jaydenkalu

Copy link
Copy Markdown
Contributor

Closes #469

Summary

Introduces a shared apiFetch / parseApiError utility so all pages surface API failures through the existing toast system rather than inconsistent inline state.

Changes

  • src/lib/api-error.ts (new): parseApiError(body) normalises {error} and {error,code,retriable} shapes into a user-friendly string with retry guidance for transient codes; apiFetch() wraps fetch and throws on non-ok
  • meters/page.tsx: remove local error state, use useToast + apiFetch — register, revoke, and load errors all push a toast

Acceptance criteria

  • ✅ All API call failures surface a common toast pattern
  • ✅ Errors include retry guidance when applicable (retriable: true / STELLAR codes)
  • ✅ Console logging unchanged; UI stays clean

- Add src/lib/api-error.ts: parseApiError() normalises {error,code,retriable}
  response shapes; apiFetch() wrapper throws human-readable error strings
- meters/page.tsx: replace inline error state with useToast pushToast()
  - registerMeter/revokeMeter use apiFetch (consistent error extraction)
  - onError/onSuccess push toast instead of setting local error state
  - Remove redundant inline error <p> and <div role=alert> blocks

Closes AnnabelJoe#469
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@jaydenkalu 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

@AnnabelJoe AnnabelJoe merged commit da5c6a2 into AnnabelJoe:main Jul 3, 2026
3 of 19 checks passed
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.

Normalize API error messaging across pages

2 participants