pkg / errors

Simple error handling primitives
https://godoc.org/github.com/pkg/errors
BSD 2-Clause "Simplified" License
8.18k stars 691 forks source link

Add json.Marshaler support to the Frame type. #197

Closed flimzy closed 5 years ago

flimzy commented 5 years ago

Fixes #196

This PR adds json.Marshaler support for the Frame type, to facilitate logging of stack traces in JSON format. The output format is equivalent to fmt.Printf("v+%"), but without newlines or tab characters.

To me, this format seems the most generally useful, but an argument could be made for outputting a JSON object instead (i.e. {"file":"...", "line": XX, "name": "..."}.).

flimzy commented 5 years ago

@puellanivis See updates. I left the json.Marshaler tests in tact, but maybe that can be removed as tacitly correct.

puellanivis commented 5 years ago

Looks good from my end.