summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/isolate.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/core/isolate.rs b/core/isolate.rs
index f876f2452..31a4c401c 100644
--- a/core/isolate.rs
+++ b/core/isolate.rs
@@ -446,7 +446,14 @@ impl Isolate {
let tc = try_catch.enter();
let mut script =
- v8::Script::compile(scope, context, source, Some(&origin)).unwrap();
+ match v8::Script::compile(scope, context, source, Some(&origin)) {
+ Some(script) => script,
+ None => {
+ let exception = tc.exception().unwrap();
+ return exception_to_err_result(scope, exception, js_error_create_fn);
+ }
+ };
+
match script.run(scope, context) {
Some(_) => Ok(()),
None => {
@@ -1153,6 +1160,16 @@ pub mod tests {
}
#[test]
+ fn syntax_error() {
+ let mut isolate = Isolate::new(StartupData::None, false);
+ let src = "hocuspocus(";
+ let r = isolate.execute("i.js", src);
+ let e = r.unwrap_err();
+ let js_error = e.downcast::<JSError>().unwrap();
+ assert_eq!(js_error.end_column, Some(11));
+ }
+
+ #[test]
fn test_encode_decode() {
run_in_task(|mut cx| {
let (mut isolate, _dispatch_count) = setup(Mode::Async);