Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
fix: missing error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ggmolly committed Jun 15, 2024
1 parent e287846 commit 4d1442a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions connection/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ func handleConnection(conn net.Conn, wg *sync.WaitGroup, server *Server) {
}
}

func (server *Server) Run() {
func (server *Server) Run() error {
listener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", server.BindAddress, server.Port))
if err != nil {
logger.LogEvent("Server", "Run", fmt.Sprintf("error listening: %v", err), logger.LOG_LEVEL_ERROR)
return
return err
}
defer listener.Close()
logger.LogEvent("Server", "Run", fmt.Sprintf("listening on %s:%d", server.BindAddress, server.Port), logger.LOG_LEVEL_INFO)
Expand All @@ -128,6 +128,7 @@ func (server *Server) Run() {
go handleConnection(conn, &wg, server)
}
wg.Wait()
return nil
}

func NewServer(bindAddress string, port int, dispatcher ServerDispatcher) *Server {
Expand Down

0 comments on commit 4d1442a

Please sign in to comment.