Improve 404 error
This commit is contained in:
parent
368f231b89
commit
bba458fe93
1 changed files with 11 additions and 2 deletions
|
@ -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 {
|
||||
return &errResponse{
|
||||
Err: err,
|
||||
|
@ -78,8 +87,8 @@ func internalError(err error) render.Renderer {
|
|||
type errResponder func(error) render.Renderer
|
||||
|
||||
var statusMapping = map[error]errResponder{
|
||||
talkgroups.ErrNoSuchSystem: recordNotFound,
|
||||
talkgroups.ErrNotFound: recordNotFound,
|
||||
talkgroups.ErrNoSuchSystem: errTextNotFound,
|
||||
talkgroups.ErrNotFound: errTextNotFound,
|
||||
pgx.ErrNoRows: recordNotFound,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue