static Local<Value> TypeError(Handle<String> message);
static Local<Value> Error(Handle<String> message);
- static Local<Message> GetMessage(Handle<Value> exception);
+ /**
+ * Creates an error message for the given exception.
+ * Will try to reconstruct the original stack trace from the exception value,
+ * or capture the current stack trace if not available.
+ */
+ static Local<Message> CreateMessage(Handle<Value> exception);
- // DEPRECATED. Use GetMessage()->GetStackTrace()
+ /**
+ * Returns the original stack trace that was captured at the creation time
+ * of a given exception, or an empty handle if not available.
+ */
static Local<StackTrace> GetStackTrace(Handle<Value> exception);
};
V8_INLINE PromiseRejectEvent GetEvent() const { return event_; }
V8_INLINE Handle<Value> GetValue() const { return value_; }
- // DEPRECATED. Use v8::Exception::GetMessage(GetValue())->GetStackTrace()
+ // DEPRECATED. Use v8::Exception::CreateMessage(GetValue())->GetStackTrace()
V8_INLINE Handle<StackTrace> GetStackTrace() const { return stack_trace_; }
private:
}
-THREADED_TEST(ExceptionGetMessage) {
+THREADED_TEST(ExceptionCreateMessage) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
v8::Handle<String> foo_str = v8_str("foo");
CHECK(error->IsObject());
CHECK(error.As<v8::Object>()->Get(message_str)->Equals(foo_str));
- v8::Handle<v8::Message> message = v8::Exception::GetMessage(error);
+ v8::Handle<v8::Message> message = v8::Exception::CreateMessage(error);
CHECK(!message.IsEmpty());
CHECK_EQ(2, message->GetLineNumber());
CHECK_EQ(2, message->GetStartColumn());
CHECK(!stackTrace.IsEmpty());
CHECK_EQ(2, stackTrace->GetFrameCount());
+ stackTrace = v8::Exception::GetStackTrace(error);
+ CHECK(!stackTrace.IsEmpty());
+ CHECK_EQ(2, stackTrace->GetFrameCount());
+
v8::V8::SetCaptureStackTraceForUncaughtExceptions(false);
// Now check message location when SetCaptureStackTraceForUncaughtExceptions
CHECK(error->IsObject());
CHECK(error.As<v8::Object>()->Get(message_str)->Equals(foo_str));
- message = v8::Exception::GetMessage(error);
+ message = v8::Exception::CreateMessage(error);
CHECK(!message.IsEmpty());
CHECK_EQ(2, message->GetLineNumber());
CHECK_EQ(9, message->GetStartColumn());
// Should be empty stack trace.
stackTrace = message->GetStackTrace();
CHECK(stackTrace.IsEmpty());
+ CHECK(v8::Exception::GetStackTrace(error).IsEmpty());
}
CcTest::global()->Set(v8_str("rejected"), message.GetPromise());
CcTest::global()->Set(v8_str("value"), message.GetValue());
v8::Handle<v8::StackTrace> stack_trace =
- v8::Exception::GetMessage(message.GetValue())->GetStackTrace();
+ v8::Exception::CreateMessage(message.GetValue())->GetStackTrace();
if (!stack_trace.IsEmpty()) {
promise_reject_frame_count = stack_trace->GetFrameCount();
if (promise_reject_frame_count > 0) {