From 15fafdc645ef6a477dd3d2ccdd36c07ff8f74188 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Tue, 23 Nov 2021 22:56:21 +0200 Subject: [PATCH] js: Pretty-print custom error types --- Userland/Utilities/js.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index d5a10ee759..fc6b275910 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -742,6 +742,13 @@ static void print_value(JS::Value value, HashTable& seen_objects) return print_date(object, seen_objects); if (is(object)) return print_error(object, seen_objects); + + auto prototype_or_error = object.internal_get_prototype_of(); + if (prototype_or_error.has_value() && prototype_or_error.value() == object.global_object().error_prototype()) + return print_error(object, seen_objects); + vm->clear_exception(); + vm->stop_unwind(); + if (is(object)) return print_regexp_object(object, seen_objects); if (is(object))