Handle connection errors properly

This commit is contained in:
Drew DeVault 2019-01-13 19:41:21 -05:00
parent 4b350dddea
commit f87fe502a6

View file

@ -77,6 +77,7 @@ func NewAccountView(
worker.PostAction(&types.Configure{Config: conf}, nil) worker.PostAction(&types.Configure{Config: conf}, nil)
worker.PostAction(&types.Connect{}, acct.connected) worker.PostAction(&types.Connect{}, acct.connected)
statusline.Set("Connecting...")
return acct return acct
} }
@ -145,9 +146,9 @@ func (acct *AccountView) connected(msg types.WorkerMessage) {
Message: types.RespondTo(msg), Message: types.RespondTo(msg),
Approved: true, Approved: true,
}, acct.connected) }, acct.connected)
default: case *types.Error:
acct.logger.Println("Connection failed.") acct.logger.Printf("%v", msg.Error)
acct.statusline.Set("Connection failed."). acct.statusline.Set(fmt.Sprintf("%v", msg.Error)).
Color(tcell.ColorRed, tcell.ColorDefault) Color(tcell.ColorRed, tcell.ColorDefault)
} }
} }