Report causes of errors
Change errors in log messages to be properly reported, with causes. This is the global whack-a-mole implied by the new facility in !936 (merged).
Fixes #680 (closed)
Specifically, I grepped the whole codebase for info!
, warn!
and error!
. I eyeballed the call and when the message was an error (according to my interpretation of the variable name), I arranged to call ErrorReport::report()
, which prints the causes.
In some places errors were logged using {:?}
which is a plausible way to try to print causes in the absence of an error reporter. I replaced those with {}
and .report()
, too.
In some places, the error was anyhow::Error, which doesn't itself implement std::error::Error
, so there we must wrap it up in tor_error::Report
. (This discrepancy is annoying, and maybe there is a better way; two extension traits both providing .report()
maybe.)
I fixed a couple of actually-wrong errors that I noticed.
I have not checked anything at debug!
or lower. Nor have I checked that the log messages make semantic sense. I have not tested this, either, but I did test the pattern in !936 (merged). We already audited the errors in our codebase for sensitive data in their causes, so I think always reporting causes is correct from a safelogging point of view. I found and fixed one exception to this, where we were logging an error type from a dependency (in the DNS proxy code).