File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -730,6 +730,14 @@ export class Decoder<A> {
730
730
map = < B > ( f : ( value : A ) => B ) : Decoder < B > =>
731
731
new Decoder ( ( json , context ) => Result . map ( f , this . decode ( json , context ) ) ) ;
732
732
733
+ /**
734
+ * Construct a new decoder that applies a transformation to an error message
735
+ * on failure. If the decoder fails then `f` will be applied to the error. If
736
+ * it succeeds the value will propagated through.
737
+ */
738
+ mapError = ( f : ( error : DecoderError ) => DecoderError ) : Decoder < A > =>
739
+ new Decoder ( ( json , context ) => Result . mapError ( f , this . decode ( json , context ) ) ) ;
740
+
733
741
/**
734
742
* Chain together a sequence of decoders. The first decoder will run, and
735
743
* then the function will determine what decoder to run second. If the result
You can’t perform that action at this time.
0 commit comments