@@ -50,9 +50,9 @@ func (e *JSONRPCError) Error() string {
5050}
5151
5252var (
53- _ error = (* JSONRPCError )(nil )
54- marshalableRT = reflect .TypeOf (new (marshalable )).Elem ()
55- unmarshalableRT = reflect .TypeOf (new (RPCErrorCodec )).Elem ()
53+ _ error = (* JSONRPCError )(nil )
54+ marshalableRT = reflect .TypeOf (new (marshalable )).Elem ()
55+ errorCodecRT = reflect .TypeOf (new (RPCErrorCodec )).Elem ()
5656)
5757
5858func (e * JSONRPCError ) val (errors * Errors ) reflect.Value {
@@ -66,12 +66,18 @@ func (e *JSONRPCError) val(errors *Errors) reflect.Value {
6666 v = reflect .New (t )
6767 }
6868
69- if v .Type ().Implements (unmarshalableRT ) {
70- _ = v .Interface ().(RPCErrorCodec ).FromJSONRPCError (* e )
69+ if v .Type ().Implements (errorCodecRT ) {
70+ if err := v .Interface ().(RPCErrorCodec ).FromJSONRPCError (* e ); err != nil {
71+ log .Errorf ("Error converting JSONRPCError (code %d) to custom error type '%s': %w" , e .Code , t .String (), err )
72+ return reflect .ValueOf (e )
73+ }
7174 }
7275
7376 if len (e .Meta ) > 0 && v .Type ().Implements (marshalableRT ) {
74- _ = v .Interface ().(marshalable ).UnmarshalJSON (e .Meta )
77+ if err := v .Interface ().(marshalable ).UnmarshalJSON (e .Meta ); err != nil {
78+ log .Errorf ("Error unmarshaling metadata for error type '%s': %w" , t .String (), err )
79+ return reflect .ValueOf (e )
80+ }
7581 }
7682
7783 if t .Kind () != reflect .Ptr {
0 commit comments