Documentation
¶
Overview ¶
Closer will help you manage errors in io.Closer used in defer consistently
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloseErrorHandler ¶
CloseErrorHandler defines the interface to use to handle io.Closer errors
type CloseErrorHandlerRequired ¶
type CloseErrorHandlerRequired struct {
Handler CloseErrorHandler
}
CloseErrorHandlerRequired can be used to compose your own struct to use a CloseErrorHandler, or fallback on DiscardErrorHandler if required
func (CloseErrorHandlerRequired) CloseHandler ¶
func (c CloseErrorHandlerRequired) CloseHandler() CloseErrorHandler
CloseHandler will return your io.Closer handler, or a DiscardErrorHandler if no handler was defined
type DiscardErrorHandler ¶
type DiscardErrorHandler struct {
}
DiscardErrorHandler will discard errors returned by io.Closer if any
func (DiscardErrorHandler) Close ¶
func (r DiscardErrorHandler) Close(c io.Closer)
Close will discard errors returned by io.Closer if any
type FuncErrorHandler ¶
type FuncErrorHandler struct {
// contains filtered or unexported fields
}
FuncErrorHandler register a function to call when closing an io.Closer
func CloseErrorHandlerFunc ¶
func CloseErrorHandlerFunc(fn func(closer io.Closer)) *FuncErrorHandler
CloseErrorHandlerFunc is a convenience method to create a FuncErrorHandler
func (FuncErrorHandler) Close ¶
func (f FuncErrorHandler) Close(closer io.Closer)
Close call the registered function with the passed io.Closer
type LogErrorHandler ¶
type LogErrorHandler struct {
// Fatal should be set to true if the logging should happen on fatal level
Fatal bool
}
LogErrorHandler will log errors returned by io.Closer
func (LogErrorHandler) Close ¶
func (r LogErrorHandler) Close(c io.Closer)
Close will log errors returned by io.Closer
type PanicErrorHandler ¶
type PanicErrorHandler struct {
}
PanicErrorHandler will panic on errors returned by io.Closer if any
func (PanicErrorHandler) Close ¶
func (r PanicErrorHandler) Close(c io.Closer)
Close will panic on errors returned by io.Closer if any