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 ruleP2universalStack: universal
api-designerror-handlinghttp
Error response payloads should not default to a success status code
An error DTO that defaults its status field to 200 is misleading; default it to an appropriate error code (e.g. 400) so failures are not reported as success.
PR: hegnar-user-ws · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | export class ErrorResponseDto { |
| 2 | @ApiProperty({ default: 200 }) |
| 3 | status: number; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | export class ErrorResponseDto { |
| 2 | @ApiProperty({ default: 400 }) |
| 3 | status: number; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)