added error codes for pagination

Signed-off-by: eyjhb <eyjhbb@gmail.com>
This commit is contained in:
eyjhbb@gmail.com 2020-05-05 11:28:31 +02:00 committed by eyjhb
parent 6891d94832
commit febc8733d2
No known key found for this signature in database
GPG key ID: 740FAE1502523BD8
2 changed files with 22 additions and 0 deletions

View file

@ -490,6 +490,18 @@ var routeDescriptors = []RouteDescriptor{
},
},
Failures: []ResponseDescriptor{
{
Name: "Invalid pagination number",
Description: "The received parameter n was invalid in some way, as described by the error code. The client should resolve the issue and retry the request.",
StatusCode: http.StatusBadRequest,
Body: BodyDescriptor{
ContentType: "application/json",
Format: errorsBody,
},
ErrorCodes: []errcode.ErrorCode{
ErrorCodePaginationNumberInvalid,
},
},
unauthorizedResponseDescriptor,
repositoryNotFoundResponseDescriptor,
deniedResponseDescriptor,

View file

@ -133,4 +133,14 @@ var (
longer proceed.`,
HTTPStatusCode: http.StatusNotFound,
})
// ErrorCodePaginationNumberInvalid is returned when the `n` parameter is
// not an integer, or `n` is negative.
ErrorCodePaginationNumberInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "PAGINATION_NUMBER_INVALID",
Message: "invalid number of results requested",
Description: `Returned when the "n" parameter (number of results
to return) is not an integer, or "n" is negative.`,
HTTPStatusCode: http.StatusBadRequest,
})
)