fix some error handling

This commit is contained in:
Specode 2013-11-04 15:13:55 +08:00
parent 64821d5df9
commit b67dc40516

View File

@ -314,6 +314,9 @@ func (c *Client) init(o *Options) error {
// Next message should be either success or failure. // Next message should be either success or failure.
name, val, err := next(c.p) name, val, err := next(c.p)
if err != nil {
return err
}
switch v := val.(type) { switch v := val.(type) {
case *saslSuccess: case *saslSuccess:
case *saslFailure: case *saslFailure:
@ -535,8 +538,8 @@ type clientError struct {
func nextStart(p *xml.Decoder) (xml.StartElement, error) { func nextStart(p *xml.Decoder) (xml.StartElement, error) {
for { for {
t, err := p.Token() t, err := p.Token()
if err != nil { if err != nil && err != io.EOF {
log.Fatal("token", err) return nil, err
} }
switch t := t.(type) { switch t := t.(type) {
case xml.StartElement: case xml.StartElement: