Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Go ¶
func Go(fn func())
Go starts a new goroutine that runs the provided function with panic recovery. Any panic in the function will be caught and logged without crashing the program.
func IfErrorPresent ¶
func IfErrorPresent(fn func() error)
IfErrorPresent executes the given function and handles any error using the configured error handler. This is useful for safely executing functions that may fail without disrupting the main flow.
func IfErrorXPresent ¶
IfErrorXPresent executes the given function that returns a value and error, handling any error. The returned value is discarded, making this useful for operations where you only care about side effects.
func InitErrorHandler ¶
func InitErrorHandler(handler ErrorHandler)
InitErrorHandler sets a custom error handler for the safe package. If handler is nil, the default error handler remains unchanged.
Types ¶
type ErrorHandler ¶
type ErrorHandler func(error)
ErrorHandler defines a function type for handling errors with contextual labels. It takes a descriptive label and the error that occurred.