[d8] Throw Error objects instead of strings by default

Change-Id: I3eaa9c7e80bea7748dc28ec4ff09fecbdd7a434d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2639767
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72220}
This commit is contained in:
Camillo Bruni 2021-01-20 14:43:42 +01:00 committed by Commit Bot
parent e6cfe142c9
commit cb020c8e21
5 changed files with 7 additions and 7 deletions

View File

@ -334,8 +334,8 @@ v8::Platform* g_default_platform;
std::unique_ptr<v8::Platform> g_platform;
static Local<Value> Throw(Isolate* isolate, const char* message) {
return isolate->ThrowException(
String::NewFromUtf8(isolate, message).ToLocalChecked());
return isolate->ThrowException(v8::Exception::Error(
String::NewFromUtf8(isolate, message).ToLocalChecked()));
}
static MaybeLocal<Value> TryGetValue(v8::Isolate* isolate,

View File

@ -9,5 +9,5 @@ import('no-such-file').catch(e => error1 = e);
import('no-such-file').catch(e => error2 = e);
%PerformMicrotaskCheckpoint();
assertEquals(error1, error2);
assertEquals(typeof error1, "string");
assertEquals(error1.message, error2.message);
assertEquals(typeof error1.message, "string");

View File

@ -48,7 +48,7 @@ async function test3() {
let x = await import('nonexistent-file.mjs');
%AbortJS('failure: should be unreachable');
} catch(e) {
assertTrue(e.startsWith('d8: Error reading'));
assertTrue(e.message.startsWith('d8: Error reading'));
ran = true;
}
}

View File

@ -50,7 +50,7 @@ async function test3() {
let x = await import('nonexistent-file.mjs');
%AbortJS('failure: should be unreachable');
} catch(e) {
assertTrue(e.startsWith('d8: Error reading'));
assertTrue(e.message.startsWith('d8: Error reading'));
ran = true;
}
}

View File

@ -18,5 +18,5 @@ var promise = __f_0();
promise.then(assertUnreachable,
err => { done = true; error = err });
%PerformMicrotaskCheckpoint();
assertTrue(error.startsWith('d8: Error reading'));
assertTrue(error.message.startsWith('d8: Error reading'));
assertTrue(done);