Skip to content

global error handler#65

Merged
Tybravo merged 2 commits into
SwiftChainn:mainfrom
samad13:features/global-error
Jul 1, 2026
Merged

global error handler#65
Tybravo merged 2 commits into
SwiftChainn:mainfrom
samad13:features/global-error

Conversation

@samad13

@samad13 samad13 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor
  1. Created custom error classes in src/errors/AppError.ts :
    • Base class AppError that extends Error , has statusCode and isOperational flag
    • Helper classes for common HTTP errors: NotFoundError , BadRequestError , UnauthorizedError , ForbiddenError , ConflictError
  2. Enhanced the global error handling middleware in src/middleware/errorHandler.ts :
    • Added handlers for Mongoose-specific errors (CastError, Duplicate Fields, ValidationError)
    • Added separate sendErrorDev and sendErrorProd functions that format errors appropriately for each environment
    • Updated to use our env.ts config for NODE_ENV check
  3. Re-created src/config/env.ts (oops, it got lost earlier!) that validates env variables with Zod
  4. Verified everything works by running tests and lint, all of which pass!
    The implementation follows the strict layered architecture, is production-ready with proper error handling and strong TypeScript types!
    Closes Backend: Set up global error handling middleware and custom Express error classes #5

@drips-wave

drips-wave Bot commented Jul 1, 2026

Copy link
Copy Markdown

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

@samad13 samad13 changed the title fix global error handler Jul 1, 2026
@Tybravo Tybravo merged commit 99ddb2d into SwiftChainn:main Jul 1, 2026
1 check failed
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.

Backend: Set up global error handling middleware and custom Express error classes

2 participants