1
Fork 0
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:
Linus Groh 2020-05-26 13:00:36 +01:00 committed by Andreas Kling
parent 2d47b30256
commit 015d65bc6f

View file

@ -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);