Skip to content

Unify FinanceEducation controllers with global AppError handling #76

@jeloskaisabel

Description

@jeloskaisabel

Is your feature request related to a problem? Please describe.
The controllers under backend-node/src/FinanceEducation still return ad‑hoc responses such as res.status(500).json({ error: 'Failed to ...' }). This differs from the unified error contract we just introduced for the rest of the backend. Because of that, these endpoints bypass AppError and the global error handler, so logs are inconsistent and the frontend cannot rely on the standardized {status,statusCode,message,errorCode,details} payload.

Describe the solution you'd like
Refactor every controller in FinanceEducation (lessons, quizzes, flashcards, learning paths, rewards, skill challenges, user stats, and gamification) to:

  • Wrap async handlers with the shared asyncHandler.
  • Replace inline res.status(...).json(...) error branches with typed AppError subclasses (NotFoundError, InternalServerError, etc.).
  • Let globalErrorHandler build the HTTP response so the payload matches the rest of the API.

Describe alternatives you've considered

  • Keeping the legacy pattern and manually mapping these specific responses on the frontend. This was rejected because it reintroduces divergent error parsing logic and undermines the new global handler.
  • Only touching endpoints that return 500. That still leaves 404/400 responses inconsistent, so the frontend would need bespoke handling per controller.

Additional context
All other feature areas (auth, currency, finance chatbot/news) already emit the unified error format. Bringing FinanceEducation in line will complete the backend cleanup and allow the frontend to consume every API through the same error parser.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions