mirror of
https://github.com/denoland/deno.git
synced 2025-01-03 12:58:54 -05:00
parent
bcd875030a
commit
d0f5cd6a06
4 changed files with 20 additions and 2 deletions
|
@ -2779,3 +2779,9 @@ itest!(spawn_stdout_inherit {
|
||||||
args: "run --quiet --unstable -A spawn_stdout_inherit.ts",
|
args: "run --quiet --unstable -A spawn_stdout_inherit.ts",
|
||||||
output: "spawn_stdout_inherit.ts.out",
|
output: "spawn_stdout_inherit.ts.out",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
itest!(error_name_non_string {
|
||||||
|
args: "run --quiet error_name_non_string.js",
|
||||||
|
output: "error_name_non_string.js.out",
|
||||||
|
exit_code: 1,
|
||||||
|
});
|
||||||
|
|
8
cli/tests/testdata/error_name_non_string.js
vendored
Normal file
8
cli/tests/testdata/error_name_non_string.js
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
class ErrorNameNonString extends Error {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.name = 42;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ErrorNameNonString();
|
4
cli/tests/testdata/error_name_non_string.js.out
vendored
Normal file
4
cli/tests/testdata/error_name_non_string.js.out
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
error: Uncaught Error
|
||||||
|
throw new ErrorNameNonString();
|
||||||
|
^
|
||||||
|
at file:///[WILDCARD]/error_name_non_string.js:[WILDCARD]
|
|
@ -164,7 +164,7 @@ fn get_property<'a>(
|
||||||
object.get(scope, key.into())
|
object.get(scope, key.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(Default, serde::Deserialize)]
|
||||||
pub(crate) struct NativeJsError {
|
pub(crate) struct NativeJsError {
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
pub message: Option<String>,
|
pub message: Option<String>,
|
||||||
|
@ -196,7 +196,7 @@ impl JsError {
|
||||||
let exception: v8::Local<v8::Object> = exception.try_into().unwrap();
|
let exception: v8::Local<v8::Object> = exception.try_into().unwrap();
|
||||||
let cause = get_property(scope, exception, "cause");
|
let cause = get_property(scope, exception, "cause");
|
||||||
let e: NativeJsError =
|
let e: NativeJsError =
|
||||||
serde_v8::from_v8(scope, exception.into()).unwrap();
|
serde_v8::from_v8(scope, exception.into()).unwrap_or_default();
|
||||||
// Get the message by formatting error.name and error.message.
|
// Get the message by formatting error.name and error.message.
|
||||||
let name = e.name.clone().unwrap_or_else(|| "Error".to_string());
|
let name = e.name.clone().unwrap_or_else(|| "Error".to_string());
|
||||||
let message_prop = e.message.clone().unwrap_or_else(|| "".to_string());
|
let message_prop = e.message.clone().unwrap_or_else(|| "".to_string());
|
||||||
|
|
Loading…
Reference in a new issue