summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-05-26 13:00:36 +0100
committerAndreas Kling <kling@serenityos.org>2020-05-26 14:36:30 +0200
commit015d65bc6f1615c96de766f8e660532fc92d2459 (patch)
tree064d3ddc04ee711cecc5692a41710003f03cc8f3 /Userland
parent2d47b30256f501bd06ff51ee2e7691d51e0386fd (diff)
downloadserenity-015d65bc6f1615c96de766f8e660532fc92d2459.zip
js: Show a "source location hint" for syntax errors :^)
Diffstat (limited to 'Userland')
-rw-r--r--Userland/js.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/Userland/js.cpp b/Userland/js.cpp
index cf8f2c9cc6..a4adc7d084 100644
--- a/Userland/js.cpp
+++ b/Userland/js.cpp
@@ -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);