mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 14:45: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()) {
|
||||
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());
|
||||
} else {
|
||||
interpreter.run(*program);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue