Skip to content

Global API Error Interceptor #76

@RUKAYAT-CODER

Description

@RUKAYAT-CODER

📌 Overview

Implement a centralized API error interceptor to normalize backend error responses and provide consistent UI handling.

🧠 Background

Currently, API errors are handled individually across components, which leads to inconsistent messaging and duplicated logic.

📐 Specifications

  • Use a single API client instance
  • Normalize error structure
  • Handle:
    • network errors
    • timeout errors
    • 4xx & 5xx responses
  • Return a typed error object

🛠 Tasks

  • Create interceptor in lib/api.ts
  • Implement parseApiError() utility
  • Refactor existing API calls to use the client

📂 Impacted Files

  • lib/api.ts
  • utils/error-handler.ts
  • All async data-fetching components

🏷 Labels

frontend error-handling DX high-priority

🤝 Contribution Guidelines

  • Follow project ESLint & Prettier rules
  • Use TypeScript types for error objects

✅ Acceptance Criteria

  • All API errors pass through the interceptor
  • UI receives a consistent error format

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions