Commit dd51311
committed
Improve reporting of HackC unit compilation errors
hackc_compile() calls into Rust via hackc::compile_unit_from_text().
This may return a Rust error that cxxbridge then throws as a C++
exception extending `std::exception`, causing cryptic errors.
For example, after D80369513 /
facebook@587ab58,
trying to run the below Hack file:
```hack
<<__EntryPoint>>
function foo(): void {
$bar = @file_get_contents('foo.txt');
}
```
returns in an error like:
```
(non-standard exception "N4rust10cxxbridge15ErrorE" was thrown)
```
So, catch and return exceptions during unit compilation.
This produces a more friendly error for the above file:
```
Fatal error: Unhandled Emitter error: Unrecoverable: Unexpected Silence operator '@' in /home/mszabo/at.hack on line -1
```1 parent 35d16dc commit dd51311
1 file changed
Lines changed: 27 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
134 | 136 | | |
135 | | - | |
136 | | - | |
| 137 | + | |
| 138 | + | |
137 | 139 | | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
143 | 149 | | |
144 | 150 | | |
145 | 151 | | |
| |||
0 commit comments