From 9998a2c91e5e6b09bcec12929bc29a170b276c10 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sun, 5 Sep 2021 20:13:06 +0100 Subject: [PATCH] LibJS: Add ErrorType::CallStackSizeExceeded I'm about to add another use of this, so let's add an ErrorType for it instead of hardcoding the message for a third time. --- Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp | 2 +- Userland/Libraries/LibJS/Runtime/ErrorTypes.h | 1 + Userland/Libraries/LibJS/Runtime/VM.h | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp index 435908b7cfa..3eb7c3a5a48 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -1946,7 +1946,7 @@ static size_t flatten_into_array(GlobalObject& global_object, Object& new_array, if (depth > 0 && value.is_array(global_object)) { if (vm.did_reach_stack_space_limit()) { - vm.throw_exception(global_object, "Call stack size limit exceeded"); + vm.throw_exception(global_object, ErrorType::CallStackSizeExceeded); return {}; } diff --git a/Userland/Libraries/LibJS/Runtime/ErrorTypes.h b/Userland/Libraries/LibJS/Runtime/ErrorTypes.h index 54041eff203..1ed7e8da731 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorTypes.h +++ b/Userland/Libraries/LibJS/Runtime/ErrorTypes.h @@ -15,6 +15,7 @@ M(BigIntFromNonIntegral, "Cannot convert non-integral number to BigInt") \ M(BigIntInvalidValue, "Invalid value for BigInt: {}") \ M(BindingNotInitialized, "Binding {} is not initialized") \ + M(CallStackSizeExceeded, "Call stack size limit exceeded") \ M(ClassConstructorWithoutNew, "Class constructor {} must be called with 'new'") \ M(ClassExtendsValueNotAConstructorOrNull, "Class extends value {} is not a constructor or null") \ M(ClassExtendsValueInvalidPrototype, "Class extends value has an invalid prototype {}") \ diff --git a/Userland/Libraries/LibJS/Runtime/VM.h b/Userland/Libraries/LibJS/Runtime/VM.h index 4b25bb3e3bc..579f5dbdc3d 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.h +++ b/Userland/Libraries/LibJS/Runtime/VM.h @@ -116,7 +116,7 @@ public: VERIFY(!exception()); // Ensure we got some stack space left, so the next function call doesn't kill us. if (did_reach_stack_space_limit()) - throw_exception(global_object, "Call stack size limit exceeded"); + throw_exception(global_object, ErrorType::CallStackSizeExceeded); else m_execution_context_stack.append(&context); }