NewError creates a new [Error] instance wrapping the given errctx.Error and category. If err is nil, it returns nil. If the error or any of its causes is [context.DeadlineExceeded] or [context.Canceled], the category is set to "timeout" regardless of the provided category.
(err errctx.Error, category string)
| 36 | // If the error or any of its causes is [context.DeadlineExceeded] or [context.Canceled], |
| 37 | // the category is set to "timeout" regardless of the provided category. |
| 38 | func NewError(err errctx.Error, category string) *Error { |
| 39 | if err == nil { |
| 40 | return nil |
| 41 | } |
| 42 | |
| 43 | // If the error or any of its causes is context.DeadlineExceeded or context.Canceled, |
| 44 | // enforce the timeout category. |
| 45 | if errors.Is(err, context.DeadlineExceeded) || errors.Is(err, context.Canceled) { |
| 46 | category = errCategoryTimeout |
| 47 | } |
| 48 | |
| 49 | return &Error{ |
| 50 | Err: err, |
| 51 | Category: category, |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | func newRouteNotDefinedError(path string) errctx.Error { |
| 56 | return RouteNotDefinedError{errctx.NewTextError( |
no outgoing calls