diff --git a/crates/sui-sdk/src/types/type_tag/mod.rs b/crates/sui-sdk/src/types/type_tag/mod.rs index 6b7f18f6b..d0a04e69c 100644 --- a/crates/sui-sdk/src/types/type_tag/mod.rs +++ b/crates/sui-sdk/src/types/type_tag/mod.rs @@ -47,13 +47,14 @@ impl std::str::FromStr for TypeTag { type Err = TypeParseError; fn from_str(s: &str) -> Result { - parse::parse_type_tag(s).map_err(|_| TypeParseError) + parse::parse_type_tag(s).map_err(|_| TypeParseError { source: s.into() }) } } -//TODO flesh out this error type #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] -pub struct TypeParseError; +pub struct TypeParseError { + source: String, +} impl std::fmt::Display for TypeParseError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { @@ -80,7 +81,9 @@ impl Identifier { pub fn new>(identifier: T) -> Result { parse::parse_identifier(identifier.as_ref()) .map(|ident| Self(ident.into())) - .map_err(|_| TypeParseError) + .map_err(|_| TypeParseError { + source: identifier.as_ref().into(), + }) } pub fn into_inner(self) -> Box { @@ -104,7 +107,7 @@ impl std::str::FromStr for Identifier { fn from_str(s: &str) -> Result { parse::parse_identifier(s) .map(|ident| Self(ident.into())) - .map_err(|_| TypeParseError) + .map_err(|_| TypeParseError { source: s.into() }) } } @@ -192,6 +195,6 @@ impl std::str::FromStr for StructTag { type Err = TypeParseError; fn from_str(s: &str) -> Result { - parse::parse_struct_tag(s).map_err(|_| TypeParseError) + parse::parse_struct_tag(s).map_err(|_| TypeParseError { source: s.into() }) } }