cockroachdb / errors

Go error library with error portability over the network
Apache License 2.0
2.07k stars 66 forks source link

Improve the structure of sentry reports #94

Closed knz closed 2 years ago

knz commented 2 years ago

Informs https://github.com/cockroachdb/cockroach/issues/76571.

This PR includes a redacted copy of the verbose error printout in the Message field of Sentry reports.

This, arguably, was desirable from the beginning, but was impossible when the errors library was first designed, because at the time we did not have a reliable redaction library. Now that we have one, we can use it.

The main visible improvement resulting from this PR is the verbose (and tree-preserving) printout of the error hidden behind barriers (e.g. those included behind assertion failures). However, this change will also now include more details about other situations, such as:

(and more generally leverages the full power of the recently redesigned errors.FormatError code)

For example, given the starting point Go code:

myErr := errutil.Newf("Hello %s %d", "world", redact.Safe(123))
myErr = errutil.Wrapf(myErr, "some prefix %s", "unseen")
myErr = errutil.NewAssertionErrorWithWrappedErrf(myErr, "assert %s %s", redact.Safe("safe"), "unsafe")

Example, before: image

Example, after: image


This change is Reviewable