Performance: Why structured errors improve API quality
MEDIUM IMPACT
Structured errors improve API response consistency and reduce client-side parsing overhead, enhancing interaction responsiveness.
throw new HttpException({ status: 'error', code: 'USER_NOT_FOUND', message: 'User does not exist' }, 404);throw new Error('Something went wrong');| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Generic error strings | N/A | N/A | Increases client parsing time | [X] Bad |
| Structured error objects | N/A | N/A | Minimal client parsing overhead | [OK] Good |