diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-03-03 17:58:24 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-03 17:58:24 +0000 |
commit | 72022a6ecf80177a28883d7016790ea41646d396 (patch) | |
tree | dbc7a0b0a45854da2f689b2191abd5fc609a6968 | |
parent | 5592322e13d0bf741130425079e37979f7637564 (diff) |
Return 404 if event given to `/context` was not found (#2245)
-rw-r--r-- | syncapi/routing/context.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/syncapi/routing/context.go b/syncapi/routing/context.go index 59113971..d07fc0c6 100644 --- a/syncapi/routing/context.go +++ b/syncapi/routing/context.go @@ -17,6 +17,7 @@ package routing import ( "database/sql" "encoding/json" + "fmt" "net/http" "strconv" @@ -102,6 +103,12 @@ func Context( id, requestedEvent, err := syncDB.SelectContextEvent(ctx, roomID, eventID) if err != nil { + if err == sql.ErrNoRows { + return util.JSONResponse{ + Code: http.StatusNotFound, + JSON: jsonerror.NotFound(fmt.Sprintf("Event %s not found", eventID)), + } + } logrus.WithError(err).WithField("eventID", eventID).Error("unable to find requested event") return jsonerror.InternalServerError() } |