ContextualError is a custom error that can wrap an existing error and provides additional context based on the function that created the error, if created via New()
type ContextualError struct { Err error Context string Message string }
func New(msg string, e error) *ContextualError
New creates a ContextualError using the provided message and wrapped Error. It also attempts to determine additional context automatically based on the file + function that is calling New(). If the context cannot be determined, it gracefully degrades into a regular wrapped Error.
Error context is in the form:
$package:$file#$line
edge-infra.dev/pkg/lib/errors.TestContextualError:pkg/errors/contextual_errors_test.go#12
func Wrap(e error) *ContextualError
Wrap creates a ContextualError without a message
func (c *ContextualError) Error() string
Error builds the error string based on the ContextualError state
func (c *ContextualError) Unwrap() error