Skip to content

v1.0.129

@youdie006 youdie006 tagged this 09 Sep 15:31
When an error passed to .Err()/.AnErr() also implements ObjectMarshaler, the
logger emitted invalid JSON. AnErr wrote the "error": key then called
o.MarshalObject(e) directly; each field method prepends a comma, so the buffer
became "error":,"code":500,... with a stray leading comma and the object's
fields leaking to the top level (json.Valid false).

Mirror the existing Object() convention: record n := len(e.buf) before
MarshalObject, then rewrite the stray leading comma at n to '{' and append '}'
(an empty marshaler yields null). The non-ObjectMarshaler string path is
unchanged.

Fixes #110
Assets 2
Loading