github.com/mvndaai/ctxerr (go): Package ctxerr is a way of creating and handling errors with extra context.  Note: Errors can be wrapped as many times as wanted but should only be handled once!  New(f) and Wrap(f)  Creating a new error or wrapping an error are as simple as:  A quick wrap function is available to avoid needing to create unused codes and messages. This function calls Wrap with an empty string for the code no message.  Note: Wrapping nil will return nil.  A context is passed in so that anywhere in code more information can be added. Adding information (aka fields) to a context is done by:  Some common field keys have been predefined to be used in this or sub packages. This includes 'FieldKeyCode' which is used to set the 'code' passed into the New/Wrap functions on the context. See the HTTP section below for more examples.  The function 'Fields' allows retrieving the fields added to the context. Using this for goroutines ensures all the data gets propagated.  Handle exists to make sure all errors are handled in the say way. It should be called only once at the top of all wrapped errors. It will run through all hooks added through configuration or fallback to the DefaultLogHook.  (i.e. HTTP handle functions or goroutines)  Hooks can be used to edit the context before creating the error and to handle the error.  If you need the context to change prior to creation of the error use 'AddCreateHook'.  To change how errors are handled use 'AddHandleHook'. Note: If you are not adding a custom logging hook it may be useful to add the default.  There is an http subpackage for handling HTTP errors. The function included returns a standardized struct filled in with details of the error. There are fields key constansts to help with this.  An "Action" is a user facing error that a user can take an action on to fix. There are helper http functions that set the status code and action in one call.
Keywords: context|errors|go