Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP1universalStack: node
error-handlinghttp-statusapi-design
Use BadRequest for invalid body fields, NotFound for missing path resources
A bad identifier inside the request body is a 400 Bad Request; reserve 404 Not Found for resources addressed by the path.
PR: vinify-backend · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | if (!profile) throw new NotFoundException(); // id came from body |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | if (!profile) throw new BadRequestException('invalid mainProfileId'); |
Explanation (EN)
Objašnjenje (HR)