Improve 404 error

This commit is contained in:
Daniel 2024-11-20 16:51:19 -05:00
parent 368f231b89
commit bba458fe93

View file

@ -67,6 +67,15 @@ func recordNotFound(err error) render.Renderer {
} }
} }
func errTextNotFound(err error) render.Renderer {
return &errResponse{
Err: err,
Code: http.StatusNotFound,
Error: "Record not found: " + err.Error(),
}
}
func internalError(err error) render.Renderer { func internalError(err error) render.Renderer {
return &errResponse{ return &errResponse{
Err: err, Err: err,
@ -78,8 +87,8 @@ func internalError(err error) render.Renderer {
type errResponder func(error) render.Renderer type errResponder func(error) render.Renderer
var statusMapping = map[error]errResponder{ var statusMapping = map[error]errResponder{
talkgroups.ErrNoSuchSystem: recordNotFound, talkgroups.ErrNoSuchSystem: errTextNotFound,
talkgroups.ErrNotFound: recordNotFound, talkgroups.ErrNotFound: errTextNotFound,
pgx.ErrNoRows: recordNotFound, pgx.ErrNoRows: recordNotFound,
} }