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 ruleP1project specificStack: node
apidryerror-handlingconsistency
Reuse the shared API response/error helper instead of ad-hoc responses
When the codebase has a shared helper for default API handling/error responses, call it in new route handlers rather than reimplementing the response shape per route.
PR: vinify-frontend · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codets
| 1 | } catch (error) { |
| 2 | res.status(500).json({ message: 'Something went wrong' }); |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | } catch (error) { |
| 2 | return handleDefaultApiCase(res, error); // shared helper used across routes |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)