Skip to content

Commit

Permalink
check if server is nil before passing pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
Laevos committed Jan 29, 2024
1 parent 126de71 commit 932b889
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion backend/servermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ type ServerManager struct {
onLogout []func()
}

var ErrUnreachable = errors.New("server is unreachable")
var (
ErrUnreachable = errors.New("server is unreachable")
ErrNilServer = errors.New("nil server provided")
)

func NewServerManager(appName string, config *Config) *ServerManager {
return &ServerManager{appName: appName, config: config}
Expand Down Expand Up @@ -156,6 +159,9 @@ func (s *ServerManager) GetServerPassword(serverID uuid.UUID) (string, error) {
}

func (s *ServerManager) SetServerPassword(server *ServerConfig, password string) error {
if server == nil {
return ErrNilServer
}
return keyring.Set(s.appName, server.ID.String(), password)
}

Expand Down

0 comments on commit 932b889

Please sign in to comment.