kg_js/error.rs
1
2//FIXME embed javascript error type
3#[derive(Debug, Clone, Eq, PartialEq, Hash)]
4pub struct JsError(String);
5
6impl std::fmt::Display for JsError {
7 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8 write!(f, "Error: {}", self.0)
9 }
10}
11
12impl std::error::Error for JsError {}
13
14impl From<String> for JsError {
15 fn from(s: String) -> Self {
16 JsError(s)
17 }
18}
19
20impl Into<String> for JsError {
21 fn into(self) -> String {
22 self.0
23 }
24}