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 {
|
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue