ToApiError wraps err into ApiError instance (if not already).
(err error)
| 132 | |
| 133 | // ToApiError wraps err into ApiError instance (if not already). |
| 134 | func ToApiError(err error) *ApiError { |
| 135 | var apiErr *ApiError |
| 136 | |
| 137 | if !errors.As(err, &apiErr) { |
| 138 | // no ApiError found -> assign a generic one |
| 139 | if errors.Is(err, sql.ErrNoRows) || errors.Is(err, fs.ErrNotExist) { |
| 140 | apiErr = NewNotFoundError("", err) |
| 141 | } else { |
| 142 | apiErr = NewBadRequestError("", err) |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return apiErr |
| 147 | } |
| 148 | |
| 149 | // ------------------------------------------------------------------- |
| 150 |
searching dependent graphs…