From 015d65bc6f1615c96de766f8e660532fc92d2459 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 26 May 2020 13:00:36 +0100 Subject: [PATCH] js: Show a "source location hint" for syntax errors :^) --- Userland/js.cpp | 3 +++ 1 file changed, 3 insertions(+) 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(error.to_string()); } else { interpreter.run(*program);