Print error cause when logging an error
The Error.cause
feature is present in SpiderMonkey 91, meaning we can provide better error logs if the cause
property is present on an error object.
This requires changing gjs_log_exception_full()
to be recursive. In the case of a thrown value that is an Object with a cause
property, the function should print something like Caused by:\n
and then log that exception. Note that the cause may not be an object, or the cause may be a circular reference, and these cases must be handled and tested.
Also consider replacing the code in gjs_throw()
that drops a second exception, to instead append the first exception to the second exception as the cause.