summaryrefslogtreecommitdiff
path: root/op_crates/web/lib.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-09-22 23:30:03 +0200
committerGitHub <noreply@github.com>2020-09-22 23:30:03 +0200
commit68fd7a927b26c3e72cf73515821450f3aa252014 (patch)
tree61536703a37c1584eef8f69f954418a68f9533f8 /op_crates/web/lib.rs
parentcf0c49191e9be862027f74f39318a3479fce3ba2 (diff)
refactor(core): support error stack, remove js_check (#7629)
This commit adds support for stack traces in "deno_core". Implementation of "Display" trait for "JsError" has been updated and in consequence "deno_core::js_check" became obsolete and removed.
Diffstat (limited to 'op_crates/web/lib.rs')
-rw-r--r--op_crates/web/lib.rs49
1 files changed, 26 insertions, 23 deletions
diff --git a/op_crates/web/lib.rs b/op_crates/web/lib.rs
index 278accd2f..1078a7917 100644
--- a/op_crates/web/lib.rs
+++ b/op_crates/web/lib.rs
@@ -2,7 +2,6 @@
use deno_core::error::uri_error;
use deno_core::error::AnyError;
-use deno_core::js_check;
use deno_core::serde_json;
use deno_core::serde_json::json;
use deno_core::serde_json::Value;
@@ -55,10 +54,12 @@ pub fn init(isolate: &mut JsRuntime) {
println!("cargo:rerun-if-changed={}", file.display());
let display_path = file.strip_prefix(display_root).unwrap();
let display_path_str = display_path.display().to_string();
- js_check(isolate.execute(
- &("deno:".to_string() + &display_path_str.replace('\\', "/")),
- &std::fs::read_to_string(&file).unwrap(),
- ));
+ isolate
+ .execute(
+ &("deno:".to_string() + &display_path_str.replace('\\', "/")),
+ &std::fs::read_to_string(&file).unwrap(),
+ )
+ .unwrap();
}
}
@@ -68,7 +69,6 @@ pub fn get_declaration() -> PathBuf {
#[cfg(test)]
mod tests {
- use deno_core::js_check;
use deno_core::JsRuntime;
use futures::future::lazy;
use futures::future::FutureExt;
@@ -92,10 +92,12 @@ mod tests {
fn test_abort_controller() {
run_in_task(|mut cx| {
let mut isolate = setup();
- js_check(isolate.execute(
- "abort_controller_test.js",
- include_str!("abort_controller_test.js"),
- ));
+ isolate
+ .execute(
+ "abort_controller_test.js",
+ include_str!("abort_controller_test.js"),
+ )
+ .unwrap();
if let Poll::Ready(Err(_)) = isolate.poll_unpin(&mut cx) {
unreachable!();
}
@@ -106,7 +108,9 @@ mod tests {
fn test_event() {
run_in_task(|mut cx| {
let mut isolate = setup();
- js_check(isolate.execute("event_test.js", include_str!("event_test.js")));
+ isolate
+ .execute("event_test.js", include_str!("event_test.js"))
+ .unwrap();
if let Poll::Ready(Err(_)) = isolate.poll_unpin(&mut cx) {
unreachable!();
}
@@ -121,8 +125,8 @@ mod tests {
if let Err(error) = result {
let error_string = error.to_string();
// Test that the script specifier is a URL: `deno:<repo-relative path>`.
- assert!(error_string.starts_with("deno:op_crates/web/01_event.js"));
- assert!(error_string.contains("Uncaught TypeError"));
+ assert!(error_string.contains("deno:op_crates/web/01_event.js"));
+ assert!(error_string.contains("TypeError"));
} else {
unreachable!();
}
@@ -136,12 +140,9 @@ mod tests {
fn test_event_target() {
run_in_task(|mut cx| {
let mut isolate = setup();
- js_check(
- isolate.execute(
- "event_target_test.js",
- include_str!("event_target_test.js"),
- ),
- );
+ isolate
+ .execute("event_target_test.js", include_str!("event_target_test.js"))
+ .unwrap();
if let Poll::Ready(Err(_)) = isolate.poll_unpin(&mut cx) {
unreachable!();
}
@@ -152,10 +153,12 @@ mod tests {
fn test_text_encoding() {
run_in_task(|mut cx| {
let mut isolate = setup();
- js_check(isolate.execute(
- "text_encoding_test.js",
- include_str!("text_encoding_test.js"),
- ));
+ isolate
+ .execute(
+ "text_encoding_test.js",
+ include_str!("text_encoding_test.js"),
+ )
+ .unwrap();
if let Poll::Ready(Err(_)) = isolate.poll_unpin(&mut cx) {
unreachable!();
}