asFiberError reports whether err is or wraps a *Error and returns it. A direct *Error is matched alloc-free by a type assertion; wrapped or joined errors fall back to errors.As.
(err error)
| 642 | // *Error is matched alloc-free by a type assertion; wrapped or joined errors |
| 643 | // fall back to errors.As. |
| 644 | func asFiberError(err error) (*Error, bool) { |
| 645 | if err == nil { |
| 646 | return nil, false |
| 647 | } |
| 648 | if e, ok := err.(*Error); ok { //nolint:errorlint // intentional fast path; wrapped/joined errors fall through to errors.As below |
| 649 | return e, true |
| 650 | } |
| 651 | // Declared here so errors.As's &target escapes only on this slow path. |
| 652 | var target *Error |
| 653 | matched := errors.As(err, &target) |
| 654 | return target, matched |
| 655 | } |
| 656 | |
| 657 | // New creates a new Fiber named instance. |
| 658 | // |
no outgoing calls
no test coverage detected