File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -731,12 +731,9 @@ impl Descriptor<DescriptorPublicKey> {
731731 }
732732
733733 let descriptor = Descriptor :: < String > :: from_str ( s) ?;
734- let descriptor = descriptor. translate_pk ( & mut keymap_pk) . map_err ( |e| {
735- Error :: Unexpected (
736- e. expect_translator_err ( "No Outer context errors" )
737- . to_string ( ) ,
738- )
739- } ) ?;
734+ let descriptor = descriptor
735+ . translate_pk ( & mut keymap_pk)
736+ . map_err ( TranslateErr :: flatten) ?;
740737
741738 Ok ( ( descriptor, keymap_pk. 0 ) )
742739 }
Original file line number Diff line number Diff line change @@ -358,6 +358,17 @@ impl<E> TranslateErr<E> {
358358 }
359359}
360360
361+ impl TranslateErr < Error > {
362+ /// If we are doing a translation where our "outer error" is the generic
363+ /// Miniscript error, eliminate the `TranslateErr` type which is just noise.
364+ pub fn flatten ( self ) -> Error {
365+ match self {
366+ Self :: TranslatorErr ( e) => e,
367+ Self :: OuterError ( e) => e,
368+ }
369+ }
370+ }
371+
361372impl < E > From < E > for TranslateErr < E > {
362373 fn from ( v : E ) -> Self { Self :: TranslatorErr ( v) }
363374}
You can’t perform that action at this time.
0 commit comments