mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 20:25:07 +00:00
js: Show a "source location hint" for syntax errors :^)
This commit is contained in:
parent
2d47b30256
commit
015d65bc6f
1 changed files with 3 additions and 0 deletions
|
@ -287,6 +287,9 @@ bool parse_and_run(JS::Interpreter& interpreter, const StringView& source)
|
||||||
|
|
||||||
if (parser.has_errors()) {
|
if (parser.has_errors()) {
|
||||||
auto error = parser.errors()[0];
|
auto error = parser.errors()[0];
|
||||||
|
auto hint = error.source_location_hint(source);
|
||||||
|
if (!hint.is_empty())
|
||||||
|
printf("%s\n", hint.characters());
|
||||||
interpreter.throw_exception<JS::SyntaxError>(error.to_string());
|
interpreter.throw_exception<JS::SyntaxError>(error.to_string());
|
||||||
} else {
|
} else {
|
||||||
interpreter.run(*program);
|
interpreter.run(*program);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue