Index
- func Ignore[T any](val T, err error) T
- func IgnoreRuntime(val any, err error) any
- func Must[T any](val T, err error) T
- func MustRuntime(val any, err error) any
- type Result
func Ignore
func Ignore[T any](val T, err error) T
Ignore is a helper that wraps a call to a function returning value and error and ignores if the error is non-nil.
func IgnoreRuntime
func IgnoreRuntime(val any, err error) any
IgnoreRuntime is a runtime version of errorsx.Ignore().
func Must
func Must[T any](val T, err error) T
Must is a helper that wraps a call to a function returning value and error and panics if the error is non-nil.
func MustRuntime
func MustRuntime(val any, err error) any
MustRuntime is a runtime version of errorsx.Must().
type Result
Result is a generic type that wraps a value and an error. It also provides a set of methods to resolve/unwrap underlying value with a specific value/error handling.
type Result[T any] struct {
// contains filtered or unexported fields
}
func Wrap
func Wrap[T any](val T, err error) Result[T]
Wrap wraps a value and an error into a Result
func (Result[T]) Catch
func (r Result[T]) Catch(fn func(error)) Result[T]
Catch executes the provided function if an error is present
func (Result[T]) Error
func (r Result[T]) Error() error
Error getter
func (Result[T]) Must
func (r Result[T]) Must() T
Must returns the value if no error is present, otherwise panics with the error
func (Result[T]) Then
func (r Result[T]) Then(fn func(T)) Result[T]
Then executes the provided function if no error is present
func (Result[T]) Value
func (r Result[T]) Value() T
Value getter
func (Result[T]) ValueOr
func (r Result[T]) ValueOr(def T) T
ValueOr returns the value if no error is present, otherwise returns the provided default value
Generated by gomarkdoc