| 3576 | } |
| 3577 | } |
| 3578 | |
| 3579 | exceptionTracker.clearError(); |
| 3580 | |
| 3581 | _symbolicating = false; |
| 3582 | return error; |
| 3583 | } |
| 3584 | |
| 3585 | void JavaScriptRuntime::onUnhandledRejectedPromise(IJavaScriptContext& jsContext, const JSValue& promiseResult) { |
| 3586 | auto currentContext = Context::currentRef(); |
| 3587 | |
| 3588 | bool shouldCrash = false; |
| 3589 | |
| 3590 | if (notifyErrorHandler(jsContext, _unhandledRejectionHandler, currentContext, promiseResult, shouldCrash)) { |
| 3591 | return; |
| 3592 | } |
| 3593 | |
| 3594 | JSExceptionTracker exceptionTracker(jsContext); |
| 3595 | auto value = jsValueToValue(jsContext, promiseResult, ReferenceInfoBuilder(), exceptionTracker); |
| 3596 | exceptionTracker.clearError(); |
| 3597 | |
| 3598 | if (value.isError()) { |
| 3599 | handleUncaughtJsErrorNoHandler(currentContext, value.getError(), /* isUnhandledPromise */ true, shouldCrash); |
| 3600 | } else { |
| 3601 | handleUncaughtJsErrorNoHandler( |
| 3602 | currentContext, Error(value.toStringBox()), /* isUnhandledPromise */ true, shouldCrash); |
| 3603 | } |
| 3604 | } |
| 3605 | |
| 3606 | Ref<JSStackTraceProvider> JavaScriptRuntime::captureCurrentStackTrace() { |
| 3607 | if (_javaScriptContext == nullptr) { |
| 3608 | return nullptr; |
| 3609 | } |
| 3610 | |
| 3611 | // Debugger and force flags always enable stack trace capture |
| 3612 | bool shouldCapture = _forceStackTraceCapture || _enableDebugger; |
| 3613 | |
| 3614 | auto listener = getListener(); |
| 3615 | if (!shouldCapture && listener && isInJsThread()) { |
| 3616 | auto currentContext = Context::currentRef(); |
| 3617 | if (currentContext != nullptr && !currentContext->getScopeName().isEmpty()) { |
| 3618 | auto runtimeTweaks = listener->getRuntimeTweaks(); |
| 3619 | shouldCapture = runtimeTweaks != nullptr && runtimeTweaks->enableScopedContextStackTraceCapture(); |
| 3620 | } |
| 3621 | } |
| 3622 | |
| 3623 | if (!shouldCapture) { |
| 3624 | return nullptr; |
| 3625 | } |
| 3626 | |
| 3627 | return doCaptureCurrentStackTrace(*_javaScriptContext); |
no test coverage detected