// Copyright (c) 2020-2023 js-sandbox contributors. Zlib license. use js_sandbox_ios::JsError; pub fn expect_error(result: Result, error_type: &str) { let err = match result { Ok(_) => panic!("Call with {error_type} must not succeed"), Err(e) => e, }; if let JsError::Runtime(e) = err { let err = e .downcast_ref::() .unwrap_or_else(|| panic!("{error_type} must lead to deno_core::error::JsError type")); println!("Expected error occurred:\n{err}"); } }