Fork of https://github.com/oxigraph/oxigraph.git for the purpose of NextGraph project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
oxigraph/js/src/utils.rs

17 lines
418 B

use js_sys::Error;
use wasm_bindgen::JsValue;
#[macro_export]
macro_rules! format_err {
($msg:literal $(,)?) => {
::wasm_bindgen::JsValue::from(::js_sys::Error::new($msg))
};
($fmt:literal, $($arg:tt)*) => {
::wasm_bindgen::JsValue::from(::js_sys::Error::new(&format!($fmt, $($arg)*)))
};
}
pub fn to_err(e: impl ToString) -> JsValue {
JsValue::from(Error::new(&e.to_string()))
}