Commit be3d0e4
authored
Fix crash when referencing non-existent target ref ID (#128)
The handleRefTargets function used Array.find() with a non-null assertion
to look up target references by refId. When a non-existent ref was
referenced (e.g., #Z when only #A and #B exist), find() returned
undefined and accessing .target on it caused a runtime TypeError.
This change adds proper error handling to throw a descriptive error
message that includes the invalid ref and lists all available refs,
making debugging much easier for users.1 parent 054cbbb commit be3d0e4
2 files changed
+20
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
162 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
163 | 170 | | |
164 | 171 | | |
165 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
0 commit comments