diff options
Diffstat (limited to '')
-rw-r--r-- | ws_connection.go | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/ws_connection.go b/ws_connection.go index abe8425..fcddbcd 100644 --- a/ws_connection.go +++ b/ws_connection.go @@ -22,8 +22,6 @@ package main import ( "context" - "errors" - "fmt" "log/slog" "sync" "sync/atomic" @@ -53,12 +51,11 @@ func handleConn( c *websocket.Conn, userID string, department string, -) (retErr error) { +) error { send := make(chan string, config.Perf.SendQ) chanPool.Store(userID, &send) defer chanPool.CompareAndDelete(userID, &send) - reportError := makeReportError(ctx, c) newCtx, newCancel := context.WithCancel(ctx) _cancel, ok := cancelPool.Load(userID) @@ -73,15 +70,6 @@ func handleConn( defer func() { cancelPool.CompareAndDelete(userID, &newCancel) - if errors.Is(retErr, context.Canceled) { - /* - * Only works if it's newCtx that has been canceled - * rather than the original ctx, which is kinda what - * we intend - */ - _ = writeText(ctx, c, "E :Context canceled") - } - /* TODO: Report errors properly */ }() /* TODO: Tell the user their current choices here. Deprecate HELLO. */ @@ -154,12 +142,7 @@ func handleConn( var userCourseTypes userCourseTypesT = make(map[string]int) err := populateUserCourseTypesAndGroups(newCtx, &userCourseTypes, &userCourseGroups, userID) if err != nil { - return reportError( - fmt.Sprintf( - "cannot populate user course types/groups: %v", - err, - ), - ) + return err } /* @@ -296,7 +279,6 @@ func handleConn( err := messageHello( newCtx, c, - reportError, mar, userID, ) @@ -307,7 +289,6 @@ func handleConn( err := messageChooseCourse( newCtx, c, - reportError, mar, userID, &userCourseGroups, @@ -320,7 +301,6 @@ func handleConn( err := messageUnchooseCourse( newCtx, c, - reportError, mar, userID, &userCourseGroups, @@ -333,7 +313,6 @@ func handleConn( err := messageConfirm( newCtx, c, - reportError, mar, userID, department, @@ -346,7 +325,6 @@ func handleConn( err := messageUnconfirm( newCtx, c, - reportError, mar, userID, ) @@ -354,7 +332,7 @@ func handleConn( return err } default: - return reportError("Unknown command " + mar[0]) + return wrapAny(errUnknownCommand, mar[0]) } } } |