#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("err: {0}")]
Other(&'static str),
#[error("JS {0}")]
JsValue(String),
#[error("Fetch req: {0}")]
FetchReq(String),
#[error("Unauthorized 401")]
HttpUnauthorized(),
#[error("Forbidden 403")]
HttpForbidden(),
#[error("Not Found 404")]
HttpNotFound(),
#[error("Conflict 409")]
HttpConflict(),
#[error("Status code {0}")]
HttpOther(u16),
}
pub type Result<T> = std::result::Result<T, Error>;
impl From<wasm_bindgen::JsValue> for Error {
fn from(err: wasm_bindgen::JsValue) -> Self {
Self::JsValue(err.as_string().unwrap_or(String::from("Unknown")))
}
}