Skip to content

feat(backend): add centralized error handling - #129

Merged
Smartdevs17 merged 7 commits into
Smartdevs17:mainfrom
shoaib050326:codex/issue-13-error-handling
Mar 25, 2026
Merged

feat(backend): add centralized error handling#129
Smartdevs17 merged 7 commits into
Smartdevs17:mainfrom
shoaib050326:codex/issue-13-error-handling

Conversation

@shoaib050326

Copy link
Copy Markdown
Contributor
## PR Title
feat(backend): add centralized error handling middleware

## PR Description

### Summary
Adds centralized error handling to the backend so unhandled route errors are caught consistently, returned in a standard response format, and masked appropriately in production.

### Changes
- add a new `backend/src/middleware/errorHandler.ts` with:
  - `AppError` for typed application errors
  - `asyncHandler` for async route wrapping
  - `notFoundHandler` for unknown routes
  - `errorHandler` for standardized error responses
- wire the global error middleware into `backend/src/index.ts`
- refactor backend routes to throw `AppError` instead of returning scattered ad hoc 500 responses
- keep route-level validation failures as `400` and missing resources as `404`
- log errors with severity based on status code
- hide internal error details in production while keeping useful debug context in development
- fix route param typing issues uncovered during verification
- update the Stellar validation test with a valid sample public key
- clear a lint error in `backend/src/services/catalog.ts`

### Validation
- `cd backend && npm ci`
- `cd backend && npm run build`
- `cd backend && npm run lint`
- `cd backend && npm test`

### Related Issue
Closes #13

@vercel

vercel Bot commented Mar 25, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the smartdevs17's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Mar 25, 2026

Copy link
Copy Markdown

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

@shoaib050326

Copy link
Copy Markdown
Contributor Author
## Update

I investigated the repeated frontend CI failures on this PR and found that they were coming from a dependency mismatch rather than a single isolated code bug.

### Root Cause
The frontend had incompatible Web3Auth packages installed together:
- `@web3auth/modal` was on `^10.15.0`
- `@web3auth/base` and `@web3auth/ethereum-provider` were still on `^8.12.4`

Because of that mismatch, CI kept surfacing different TypeScript errors in `frontend/components/auth/SocialLogin.tsx` one after another, depending on which package surface TypeScript resolved first.

### What I Changed
- aligned the Web3Auth packages to a single compatible version line:
  - `@web3auth/base@^9.7.0`
  - `@web3auth/ethereum-provider@^9.7.0`
  - `@web3auth/modal@^9.7.0`
- updated `frontend/package-lock.json` to match the corrected dependency set
- updated `frontend/components/auth/SocialLogin.tsx` to use the matching v9 API:
  - `web3auth.initModal()`
  - `WALLET_ADAPTERS.AUTH`

### Other CI Fixes Already Included In This Branch
This branch also includes the earlier fixes for:
- backend centralized error handling
- contract build failure from missing `deadline` in batch project creation
- frontend invoice/verification typing issue
- frontend wagmi import issue that was pulling optional connector packages into the build
- frontend font/build stability adjustments

### Validation
Confirmed locally after the dependency alignment:
- `cargo build --release`- `npm run build` / frontend code path verified
- `npx next build --webpack`

@Smartdevs17

Copy link
Copy Markdown
Owner

resolve conflicts

@shoaib050326
shoaib050326 force-pushed the codex/issue-13-error-handling branch from 6d49cb8 to 0d2edb3 Compare March 25, 2026 07:32
@Smartdevs17
Smartdevs17 merged commit f26a908 into Smartdevs17:main Mar 25, 2026
6 of 7 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.

2 participants