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).
frontend ruleP1universalStack: react
error-handlingasyncuxcorrectness
Open success-dependent UI inside try, not finally
Put UI that should only appear after a successful fetch (e.g. opening a modal pre-filled with the result) inside the try block, not in finally where it runs even when the fetch threw.
PR: vinify-frontend · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codets
| 1 | try { |
| 2 | const item = await getItem(id); |
| 3 | setSelected(item); |
| 4 | } catch (error) { |
| 5 | showError(error); |
| 6 | } finally { |
| 7 | openModal(); // opens an empty modal even after a failed fetch |
| 8 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | try { |
| 2 | const item = await getItem(id); |
| 3 | setSelected(item); |
| 4 | openModal(); // only opens on success |
| 5 | } catch (error) { |
| 6 | showError(error); |
| 7 | } |
Explanation (EN)
Objašnjenje (HR)