-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
The SetErrPrefix method introduced in #2023 is nice, but I wanted to set it to an empty string "", but discovered that this is treated the same as if you had not set it at all. For example, I want to print structured JSON with an "error" field or similar. To do this and return a non-zero exit code to the OS requires more hoop jumping unless I can remove teh prefix.
It would be preferable if this were a *string field, which would allow setting it to an empty string.
Another unexpected aspect of the prefix, is that a space is always inserted because it is applied with c.PrintErrln(c.ErrPrefix(), err.Error()). Perhaps at this spot, it could simply run c.PrintErrln(err.Error()) if we find that c.ErrPrefix() is ""? This way the prefix field could remain a string (no pointer).