Better error handling

This commit is contained in:
Ian Gulliver
2022-10-30 20:33:28 +00:00
parent 3ff3fa59eb
commit 766bf4d756

View File

@@ -58,9 +58,9 @@ func (ic *ImapClient) Close() {
func (ic *ImapClient) List(ref, name string) ([]*imap.MailboxInfo, error) { func (ic *ImapClient) List(ref, name string) ([]*imap.MailboxInfo, error) {
ch := make(chan *imap.MailboxInfo, 10) ch := make(chan *imap.MailboxInfo, 10)
var err error done := make(chan error)
go func() { go func() {
err = ic.cli.List(ref, name, ch) done <- ic.cli.List(ref, name, ch)
}() }()
ret := []*imap.MailboxInfo{} ret := []*imap.MailboxInfo{}
@@ -68,6 +68,7 @@ func (ic *ImapClient) List(ref, name string) ([]*imap.MailboxInfo, error) {
ret = append(ret, mbox) ret = append(ret, mbox)
} }
err := <-done
if err != nil { if err != nil {
return nil, err return nil, err
} else { } else {