Error text
This commit is contained in:
parent
82d2d5c340
commit
6acae39cba
4 changed files with 13 additions and 1 deletions
|
@ -1,5 +1,11 @@
|
|||
package common
|
||||
|
||||
import "errors"
|
||||
|
||||
var (
|
||||
ErrPageOutOfRange = errors.New("requested page out of range")
|
||||
)
|
||||
|
||||
type Pagination struct {
|
||||
Page *int `json:"page"`
|
||||
PerPage *int `json:"perPage"`
|
||||
|
|
|
@ -115,7 +115,7 @@ func (s *store) Calls(ctx context.Context, p CallsParams) (rows []database.ListC
|
|||
}
|
||||
|
||||
if offset > int32(count) {
|
||||
return fmt.Errorf("requested page out of range")
|
||||
return common.ErrPageOutOfRange
|
||||
}
|
||||
|
||||
rows, err = db.ListCallsP(ctx, par)
|
||||
|
|
|
@ -133,6 +133,10 @@ func (s *store) Incidents(ctx context.Context, p IncidentsParams) (rows []databa
|
|||
return err
|
||||
}
|
||||
|
||||
if offset > int32(count) {
|
||||
return common.ErrPageOutOfRange
|
||||
}
|
||||
|
||||
rows, err = db.ListIncidentsP(ctx, dbParam)
|
||||
return err
|
||||
}, pgx.TxOptions{})
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"dynatron.me/x/stillbox/internal/common"
|
||||
"dynatron.me/x/stillbox/pkg/talkgroups/tgstore"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
|
@ -128,6 +129,7 @@ var statusMapping = map[error]errResponder{
|
|||
tgstore.ErrReference: constraintErrText,
|
||||
ErrBadUID: unauthErrText,
|
||||
ErrBadAppName: unauthErrText,
|
||||
common.ErrPageOutOfRange: badRequestErrText,
|
||||
}
|
||||
|
||||
func autoError(err error) render.Renderer {
|
||||
|
|
Loading…
Reference in a new issue