@@ -140,24 +140,17 @@ mod prelude {
140140pub type Result < T , E = Error > = core:: result:: Result < T , E > ;
141141
142142#[ allow( missing_docs) ]
143- #[ derive( Debug , PartialEq , Eq ) ]
143+ #[ derive( Debug , thiserror :: Error , PartialEq , Eq ) ]
144144pub enum Error {
145- /// The length must not be odd.
145+ #[ error( transparent) ]
146+ ParseIntError ( #[ from] core:: num:: ParseIntError ) ,
147+ #[ error( transparent) ]
148+ Utf8Error ( #[ from] core:: str:: Utf8Error ) ,
149+
150+ #[ error( "length must not be odd" ) ]
146151 InvalidLength ,
147- /// Found the invalid character at `index`.
148- InvalidCharacter {
149- /// The invalid character.
150- character : char ,
151- /// The invalid character's index.
152- index : usize ,
153- } ,
154- /// The data can not fit the array/slice length well.
155- MismatchedLength {
156- /// Expected length.
157- expect : usize ,
158- } ,
159- /// Failed to parse the hex number from hex string.
160- Utf8Error ( core:: str:: Utf8Error ) ,
161- /// Failed to parse the hex number from hex string.
162- ParseIntError ( core:: num:: ParseIntError ) ,
152+ #[ error( "invalid character({character}) at index({index})" ) ]
153+ InvalidCharacter { character : char , index : usize } ,
154+ #[ error( "mismatched length, expected {expect}" ) ]
155+ MismatchedLength { expect : usize } ,
163156}
0 commit comments