use qwac_sys::core::error_get;
use std::fmt;
#[derive(Debug, Eq, PartialEq)]
pub struct Error(String);
impl Error {
pub fn from_code(code: i32) -> Self {
let error = *unsafe { Box::from_raw(error_get(code)) };
Self(String::from_utf8(error.into()).expect("Application gave non-utf8 error"))
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
}
}
impl std::error::Error for Error {}