# Xerror
Package xerror implements helpers for errors.
# Source:
# Usage:
import (
"github.com/duke-git/lancet/v2/xerror"
)
# Documentation
# Unwrap
Unwrap if err is nil then it returns a valid value. If err is not nil, Unwrap panics with err.
Signature:
func Unwrap[T any](val T, err error) T
Example:
package main
import (
"fmt"
"github.com/duke-git/lancet/v2/xerror"
)
func main() {
_, err := strconv.Atoi("4o2")
defer func() {
v := recover()
fmt.Println(err.Error()) // err.Error() == v.(*strconv.NumError).Error()
}()
xerror.Unwrap(strconv.Atoi("4o2"))
}