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
loggingerror-handlingcorrectnessobservability
Branch logging on the actual result, never log success unconditionally
When an error-capturing wrapper returns a result object instead of throwing, check that result before logging success; an unconditional success log after a caught error produces misleading ops logs.
PR: vinify-backend · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | await Result.process(() => this.processCellar(cellar)); // swallows + logs error |
| 2 | this.logger.log('Successfully processed cellar'); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const result = await Result.process(() => this.processCellar(cellar)); |
| 2 | if (result.error) return; |
| 3 | this.logger.log('Successfully processed cellar'); |
Explanation (EN)
Objašnjenje (HR)