Evaluates the JS `code` within `scope`, returning either the result of the computation or the stringified exception if one happened.
(scope: &mut v8::HandleScope<'s>, code: &str)
| 271 | /// Evaluates the JS `code` within `scope`, returning either the result of the |
| 272 | /// computation or the stringified exception if one happened. |
| 273 | fn eval<'s>(scope: &mut v8::HandleScope<'s>, code: &str) -> Result<v8::Local<'s, v8::Value>> { |
| 274 | let mut tc = v8::TryCatch::new(scope); |
| 275 | let mut scope = v8::EscapableHandleScope::new(&mut tc); |
| 276 | let source = v8::String::new(&mut scope, code).unwrap(); |
| 277 | let script = v8::Script::compile(&mut scope, source, None).unwrap(); |
| 278 | match script.run(&mut scope) { |
| 279 | Some(val) => Ok(scope.escape(val)), |
| 280 | None => { |
| 281 | drop(scope); |
| 282 | assert!(tc.has_caught()); |
| 283 | bail!( |
| 284 | "{}", |
| 285 | tc.message() |
| 286 | .unwrap() |
| 287 | .get(&mut tc) |
| 288 | .to_rust_string_lossy(&mut tc) |
| 289 | ) |
| 290 | } |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | fn get_diff_value( |
| 295 | val: &v8::Local<'_, v8::Value>, |
no test coverage detected