Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
Add convert from strings
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Lodder <[email protected]>
  • Loading branch information
mikelodder7 authored and appetrosyan committed Feb 9, 2023
1 parent 64b4469 commit 8458c0f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions ursa_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ serde = "1.0"
serde_bare = "0.5"
serde_cbor = "0.11"
serde_json = "1.0"
string-error = "0.1"
thiserror = "1.0"
19 changes: 19 additions & 0 deletions ursa_core/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use string_error::*;
use thiserror::Error as ThisError;

/// The common errors that can occur in Ursa
Expand Down Expand Up @@ -32,5 +33,23 @@ pub enum UrsaError {
Kind(Box<dyn std::error::Error>),
}

impl From<String> for UrsaError {
fn from(value: String) -> Self {
Self::Kind(into_err(value))
}
}

impl From<&String> for UrsaError {
fn from(value: &String) -> Self {
Self::Kind(into_err(value.clone()))
}
}

impl From<&str> for UrsaError {
fn from(value: &str) -> Self {
Self::Kind(new_err(value))
}
}

/// Results returned from ursa components
pub type UrsaResult<T> = anyhow::Result<T, UrsaError>;

0 comments on commit 8458c0f

Please sign in to comment.