Is404Error returns true if the given error should return a 404 status code. Both actual 404s and unauthorized errors should return 404s to not leak information about the existence of resources.
(err error)
| 119 | // Both actual 404s and unauthorized errors should return 404s to not leak |
| 120 | // information about the existence of resources. |
| 121 | func Is404Error(err error) bool { |
| 122 | if err == nil { |
| 123 | return false |
| 124 | } |
| 125 | |
| 126 | // This tests for dbauthz.IsNotAuthorizedError and rbac.IsUnauthorizedError. |
| 127 | if IsUnauthorizedError(err) { |
| 128 | return true |
| 129 | } |
| 130 | return xerrors.Is(err, sql.ErrNoRows) |
| 131 | } |
| 132 | |
| 133 | func IsUnauthorizedError(err error) bool { |
| 134 | if err == nil { |
no test coverage detected