improve error handling for listen
This commit is contained in:
parent
097e95bdb1
commit
d983bfb9a3
1 changed files with 7 additions and 6 deletions
|
@ -104,7 +104,7 @@ func (s *Signald) Close() error {
|
|||
}
|
||||
|
||||
// Listen listens for events from signald
|
||||
func (s *Signald) Listen(c chan client_protocol.BasicResponse) {
|
||||
func (s *Signald) Listen(c chan client_protocol.BasicResponse) error {
|
||||
for {
|
||||
msg, err := s.readNext()
|
||||
if err == io.EOF {
|
||||
|
@ -112,7 +112,11 @@ func (s *Signald) Listen(c chan client_protocol.BasicResponse) {
|
|||
if c != nil {
|
||||
close(c)
|
||||
}
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if msg.Type == "unexpected_error" {
|
||||
|
@ -174,9 +178,6 @@ func (s *Signald) readNext() (b client_protocol.BasicResponse, err error) {
|
|||
} else {
|
||||
err = json.NewDecoder(s.socket).Decode(&b)
|
||||
}
|
||||
if err != nil {
|
||||
log.Println("signald-go: error decoding message from signald:", err)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue