Handle connection errors properly

This commit is contained in:
Drew DeVault 2019-01-13 19:41:21 -05:00
parent 4b350dddea
commit f87fe502a6
1 changed files with 4 additions and 3 deletions

View File

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