File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed
credential/cargo-credential/src Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -80,14 +80,7 @@ impl From<&str> for Error {
80
80
81
81
impl From < anyhow:: Error > for Error {
82
82
fn from ( value : anyhow:: Error ) -> Self {
83
- let mut prev = None ;
84
- for e in value. chain ( ) . rev ( ) {
85
- prev = Some ( Box :: new ( StringTypedError {
86
- message : e. to_string ( ) ,
87
- source : prev,
88
- } ) ) ;
89
- }
90
- Error :: Other ( prev. unwrap ( ) )
83
+ Error :: from ( Box :: new ( StringTypedError :: from ( value) ) )
91
84
}
92
85
}
93
86
@@ -116,6 +109,19 @@ impl std::fmt::Display for StringTypedError {
116
109
}
117
110
}
118
111
112
+ impl From < anyhow:: Error > for StringTypedError {
113
+ fn from ( value : anyhow:: Error ) -> Self {
114
+ let mut prev = None ;
115
+ for e in value. chain ( ) . rev ( ) {
116
+ prev = Some ( StringTypedError {
117
+ message : e. to_string ( ) ,
118
+ source : prev. map ( Box :: new) ,
119
+ } ) ;
120
+ }
121
+ prev. unwrap ( )
122
+ }
123
+ }
124
+
119
125
/// Serializer / deserializer for any boxed error.
120
126
/// The string representation of the error, and its `source` chain can roundtrip across
121
127
/// the serialization. The actual types are lost (downcast will not work).
You can’t perform that action at this time.
0 commit comments