summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--wsm.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/wsm.go b/wsm.go
index 0cf8809..b942ad2 100644
--- a/wsm.go
+++ b/wsm.go
@@ -82,6 +82,10 @@ func messageChooseCourse(ctx context.Context, c *websocket.Conn, reportError rep
courseID := int(_courseID)
course := getCourseByID(courseID)
+ if course == nil {
+ return reportError("nil course")
+ }
+
err = func() (returnedError error) { /* Named returns so I could modify them in defer */
tx, err := db.Begin(ctx)
if err != nil {
@@ -182,6 +186,10 @@ func messageUnchooseCourse(ctx context.Context, c *websocket.Conn, reportError r
courseID := int(_courseID)
course := getCourseByID(courseID)
+ if course == nil {
+ return reportError("nil course")
+ }
+
ct, err := db.Exec(
ctx,
"DELETE FROM choices WHERE userid = $1 AND courseid = $2",