-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
386 additions
and
107 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,29 @@ | ||
// The Serialize and Deserialize traits are derived to ensure that Errors can be | ||
// transmitted to or from a server, which is necessary for them to function as Resources. | ||
#[derive(thiserror::Error, serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq)] | ||
pub enum Error { | ||
#[error("An error occurred: {0}")] | ||
GenericError(String), | ||
Generic(String), | ||
|
||
#[error("A Secret error occurred: {0}")] | ||
SecretError(String), | ||
#[error("An error related to Secret occurred: {0}")] | ||
Secret(String), | ||
|
||
#[error(transparent)] | ||
KeplrError(#[from] ::keplr::Error), | ||
#[error("An error related to Keplr occurred: {0}")] | ||
Keplr(#[from] crate::keplr::Error), | ||
|
||
#[error("Keplr is not enabled!")] | ||
KeplrDisabled, | ||
} | ||
|
||
impl From<rsecret::Error> for Error { | ||
fn from(error: rsecret::Error) -> Self { | ||
Error::SecretError(error.to_string()) | ||
Error::Secret(error.to_string()) | ||
} | ||
} | ||
|
||
impl Error { | ||
pub fn generic(message: impl ToString) -> Self { | ||
let message = message.to_string(); | ||
Error::GenericError(message) | ||
Error::Generic(message) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#[derive(thiserror::Error, serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq)] | ||
pub enum Error { | ||
#[error("An error occurred in JavaScript: {0}")] | ||
JsError(String), | ||
// #[error("Serialization Error: {0}")] | ||
// SerializationError(#[from] serde_wasm_bindgen::Error), | ||
} | ||
|
||
impl From<js_sys::wasm_bindgen::JsValue> for Error { | ||
fn from(error: js_sys::wasm_bindgen::JsValue) -> Self { | ||
let message = js_sys::Error::from(error) | ||
.message() | ||
.as_string() | ||
.unwrap_or("unknown JS error".to_string()); | ||
Error::JsError(message) | ||
} | ||
} |
Oops, something went wrong.