Documentation
¶
Overview ¶
fatal, LitFill <marrazzy54 at email dot com> library for fatal assignment or logging (error management)
Index ¶
- func Assign[T any](val T, err error, msg string, log ...any) T
- func AssignR[T any](r ErrorResult[T], msg string, log ...any) T
- func AssignV2[T any](val T, err error, msg string, log ...any) T
- func Debug(msg string, log ...any)
- func Error(msg string, log ...any)
- func Info(msg string, log ...any)
- func Log(err error, msg string, log ...any)
- func SetLogger(logr Logger)
- type ErrorHandler
- type ErrorResult
- type Logger
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Assign ¶
Assign wraps function call returning a `val` and error to log it if error != nil using `log/slog` so it has `msg` and `log`. example:
file := Assign(os.Create("log.txt"),
"Can not create file",
"file", "log.txt"
)
Types ¶
type ErrorHandler ¶ added in v0.0.3
ErrorHandler represents a function that handles an error
type ErrorResult ¶ added in v0.0.3
func Errorable ¶ added in v0.0.3
func Errorable[T any](val T, err error) ErrorResult[T]
type Result ¶ added in v0.0.3
type Result[T, E any] interface { Error() E Value() T Failure() bool Success() bool Map(func(T) any) Result[any, E] FlatMap(func(T) Result[T, E]) Result[T, E] Or(ErrorHandler[T, E]) Result[T, E] }
Result represents a result of an operation that can fail
Click to show internal directories.
Click to hide internal directories.