Commit ae0b99d
committed
Throw errors from HTML parsing
Replace some TODOs with actual exception throwing. The exceptions aren’t
great, but at least they’re better than just ignoring the errors.
The first case doesn’t have a test because, as far as I can tell, it’s
basically impossible to trigger. There are apparently very few
situations where loadHTML() will return false [1] rather than trying to
fix up the markup somehow, and we’re already guaranteeing that the HTML
isn’t empty and that the options are valid.
The second case can raise a variety of errors; just test one of them.
Turning the array of LibXMLError instances (which aren’t Throwable) into
a “tree” / “stack” of Exception instances isn’t super nice, but better
than doing nothing or only throwing an Exception for the first error.
Note that we have to ignore / skip one error: libxml may complain about
“invalid” <template> tags, but we need those for SFC handling.
[1]: https://stackoverflow.com/a/79055330/14202371 parent 158a0ff commit ae0b99d
2 files changed
+16
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | | - | |
46 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
47 | 53 | | |
48 | 54 | | |
49 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
66 | 73 | | |
0 commit comments