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: node
resilienceretryerror-handling
Retry a flaky operation once before treating it as a real error
For operations that intermittently fail on the first attempt, retry once and only surface an error if the retry also fails.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codejs
| 1 | const token = await getToken(); // throws on a transient first-attempt failure |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejs
| 1 | let token; |
| 2 | try { |
| 3 | token = await getToken(); |
| 4 | } catch { |
| 5 | token = await getToken(); // one retry; failure here is a real error |
| 6 | } |
Explanation (EN)
Objašnjenje (HR)