Skip to content

Commit f13d29d

Browse files
committed
Enhance Error message formatting to return JSON string if applicable.
1 parent dae3220 commit f13d29d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

errors/errors.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ type Error struct {
2323
}
2424

2525
func (e *Error) Error() string {
26+
var js json.RawMessage
27+
if json.Unmarshal([]byte(e.Message), &js) == nil {
28+
return string(js)
29+
}
30+
2631
if e.cause != nil {
2732
return fmt.Sprintf("%s: %s (cause: %s)", e.Type, e.Message, e.cause)
2833
}

0 commit comments

Comments
 (0)