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: universal
error-handlingresiliencefallbackasync
Catch non-critical sub-step failures so they don't abort the whole operation
If an optional enrichment step (e.g. generating metadata) fails, catch it and continue with a fallback rather than letting it throw and discard the rest of a successful operation.
PR: hegnar-journalist-boost · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | const meta = await generateMetadata(input); // throws -> entire push aborts |
| 2 | await push({ ...payload, ...meta }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const meta = await generateMetadata(input).catch((e) => { |
| 2 | logger.warn('metadata generation failed', e); |
| 3 | return null; |
| 4 | }); |
| 5 | await push({ ...payload, ...(meta ?? {}) }); // proceed without the optional part |
Explanation (EN)
Objašnjenje (HR)