I am using anyhow in a CLI project, which filters out broken pipe errors at the top level main. When writing JSON directly to a closed stdout the returned root_cause is the JSON ser::Error itself, not the underlying io::Error.
It turns out, the implementation of Error::source for ser::Error does not return the actual source of the JSON Error, but the transitive source of its inner io::Error. This was introduced in #992.
I think it would probably be better to return the correct Error::source and simply format the io case for ser::Error as an io error occured to avoid the dupe message.
I am using
anyhow
in a CLI project, which filters out broken pipe errors at the top level main. When writing JSON directly to a closedstdout
the returnedroot_cause
is the JSONser::Error
itself, not the underlyingio::Error
.It turns out, the implementation of
Error::source for ser::Error
does not return the actual source of the JSONError
, but the transitive source of its innerio::Error
. This was introduced in #992.I think it would probably be better to return the correct
Error::source
and simply format theio
case forser::Error
asan io error occured
to avoid the dupe message.