Skip to content

[800] [S4] Add request timeout and standardise error parsing in the API client#818

Merged
Akshola00 merged 2 commits into
Web3Novalabs:mainfrom
Goodnessukaigwe:fix/800-add-request-timeout-and-standardise-error-parsing-in-the-api-client
Jun 30, 2026
Merged

[800] [S4] Add request timeout and standardise error parsing in the API client#818
Akshola00 merged 2 commits into
Web3Novalabs:mainfrom
Goodnessukaigwe:fix/800-add-request-timeout-and-standardise-error-parsing-in-the-api-client

Conversation

@Goodnessukaigwe

Copy link
Copy Markdown
Contributor

Summary

  • Sets the default API client request timeout to 10 seconds (10_000 ms)
  • Adds a type-safe parseApiError(err: unknown): string helper in nevo_frontend/lib/errors.ts
  • Refactors all API-related catch blocks to use the shared helper

API timeout configuration

The ApiClient default timeout is changed from 15s to 10s. Individual requests can still override via the existing timeout option in RequestConfig.

parseApiError design

Resolution order:

  1. Axios-like response.data.message
  2. Axios-like response.data.error
  3. ApiError.data.message / ApiError.data.error (fetch-based client)
  4. Error.message
  5. Fallback: "Something went wrong. Please try again."

Uses manual type guards for axios-shaped errors (no axios dependency added — the client uses fetch).

Migrated error-handling locations

  • src/store/poolsStore.tsfetchPools, fetchPool
  • app/login/page.tsx — authentication flow
  • app/profile/page.tsx — profile save
  • app/pools/new/page.tsx — pool creation submit (validation 400 handling unchanged)
  • app/pools/[id]/page.tsx — pool close
  • components/DonateModal.tsx — donation flow

Validation results

  • npm run build passes
  • Lint passes on all changed files
  • Unit tests added in __tests__/errors.test.ts covering axios shapes, ApiError, network/fallback cases

Closes #800

Made with Cursor

Centralises API error message extraction and adopts it across all API catch blocks.

Co-authored-by: Cursor <cursoragent@cursor.com>
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

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

@Akshola00 Akshola00 merged commit e396723 into Web3Novalabs:main Jun 30, 2026
3 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.

[S4] Add request timeout and standardise error parsing in the API client

2 participants