@@ -2020,8 +2020,6 @@ void WScriptJsrt::PromiseRejectionTrackerCallback(JsValueRef promise, JsValueRef
2020
2020
{
2021
2021
Assert (promise != JS_INVALID_REFERENCE);
2022
2022
Assert (reason != JS_INVALID_REFERENCE);
2023
- JsValueRef strValue;
2024
- JsErrorCode error = ChakraRTInterface::JsConvertValueToString (reason, &strValue);
2025
2023
2026
2024
if (!handled)
2027
2025
{
@@ -2032,11 +2030,32 @@ void WScriptJsrt::PromiseRejectionTrackerCallback(JsValueRef promise, JsValueRef
2032
2030
wprintf (_u (" Promise rejection handled\n " ));
2033
2031
}
2034
2032
2033
+ JsPropertyIdRef stackPropertyID;
2034
+ JsErrorCode error = ChakraRTInterface::JsCreatePropertyId (" stack" , strlen (" stack" ), &stackPropertyID);
2035
2035
if (error == JsNoError)
2036
2036
{
2037
- AutoString str (strValue);
2038
- if (str.GetError () == JsNoError)
2037
+ JsValueRef stack;
2038
+ error = ChakraRTInterface::JsGetProperty (reason, stackPropertyID, &stack);
2039
+ if (error == JsNoError)
2040
+ {
2041
+ JsValueRef stackStrValue;
2042
+ error = ChakraRTInterface::JsConvertValueToString (stack, &stackStrValue);
2043
+ if (error == JsNoError)
2044
+ {
2045
+ AutoString str (stackStrValue);
2046
+ wprintf (_u (" %ls\n " ), str.GetWideString ());
2047
+ }
2048
+ }
2049
+ }
2050
+
2051
+ if (error != JsNoError)
2052
+ {
2053
+ // weren't able to print stack, so just convert reason to a string
2054
+ JsValueRef strValue;
2055
+ error = ChakraRTInterface::JsConvertValueToString (reason, &strValue);
2056
+ if (error == JsNoError)
2039
2057
{
2058
+ AutoString str (strValue);
2040
2059
wprintf (_u (" %ls\n " ), str.GetWideString ());
2041
2060
}
2042
2061
}
0 commit comments