You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of CL 20356, if there is an error in encoding/json.mapEncoder.encode, it returns an error of type MarshalerError. But the message printed by MarshalerError's Error method refers to MarshalJSON, and that method was never called. Every other use of MarshalerError is in the context of a call to MarshalJSON or MarshalText. I think that mapEncoder.encode should use a different error type; I note that stringEncoder simply calls fmt.Errorf.
Also we should probably change MarshalerError's message to refer to MarshalText as well as MarshalJSON.
Would it violate the compatibility guarantee to change the error type from MarshalerError to a fmt.Errorf? Perhaps only updating the MarshalerError's message would be sufficient?
This is permitted by the Go 1 compatibility guarantee. We shouldn't change it if we think that people are relying the returned type, but that doesn't seem particularly likely to me.
As of CL 20356, if there is an error in
encoding/json.mapEncoder.encode
, it returns an error of typeMarshalerError
. But the message printed byMarshalerError
'sError
method refers toMarshalJSON
, and that method was never called. Every other use ofMarshalerError
is in the context of a call toMarshalJSON
orMarshalText
. I think thatmapEncoder.encode
should use a different error type; I note thatstringEncoder
simply callsfmt.Errorf
.Also we should probably change
MarshalerError
's message to refer toMarshalText
as well asMarshalJSON
.CC @augustoroman
The text was updated successfully, but these errors were encountered: