Documentation ¶
Overview ¶
Package warnonerror contains custom versions of common functions/methods that always log a warning in case of error.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Close ¶
Close wraps a resource.Close() call and logs the error, if any, adding a custom message.
This function is intended to be used as a better alternative to completely ignoring an error in cases where there isn't any obvious reason to handle it explicitly.
Its allows to turn ugly error-logging code such as:
defer func() { err := resource.Close() if err != nil { log.Printf("Warning: ignoring error (%v)", err) } }()
into a simplified pattern of:
defer warnonerror.Close(resource, "Warning: ignoring error")
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.