From bba458fe93706ccfee58b2dd688428718429da33 Mon Sep 17 00:00:00 2001 From: Daniel Ponte Date: Wed, 20 Nov 2024 16:51:19 -0500 Subject: [PATCH] Improve 404 error --- pkg/rest/api.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/rest/api.go b/pkg/rest/api.go index 3ed9adc..671aad4 100644 --- a/pkg/rest/api.go +++ b/pkg/rest/api.go @@ -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, }