ThrowScope is a mechanism for throwing JS exceptions and for ensuring their correct handling in C++ code.
If a function can throw a JS exception, whether directly or indirectly by calling other functions that throw exceptions, it should declare a ThrowScope at the top of the function using the DECLARE_THROW_SCOPE macro. The scope supports throwing exceptions and in debug builds verifies that the required exception checks have been missed. Its presence is also an indication that the function can throw, and its callers should check for exceptions as explained below.
Let's consider this example of a function that calls two other functions, both of which may throw JS exceptions. We give it a throw scope and initially write the code as follows:
int functionA(VM& vm) {
	auto scope = DECLARE_THROW_SCOPE(vm);
	int x = functionB(vm);
	int y = functionC(vm);