gearman-go/worker/error.go

29 lines
569 B
Go
Raw Normal View History

2013-08-30 12:36:57 +08:00
package worker
import (
"bytes"
"errors"
"fmt"
)
var (
2013-12-26 12:06:47 +08:00
ErrNoneAgents = errors.New("None active agents")
ErrNoneFuncs = errors.New("None functions")
ErrTimeOut = errors.New("Executing time out")
ErrUnknown = errors.New("Unknown error")
2013-08-30 12:36:57 +08:00
)
// Extract the error message
func getError(data []byte) (err error) {
2013-08-30 12:36:57 +08:00
rel := bytes.SplitN(data, []byte{'\x00'}, 2)
if len(rel) != 2 {
err = fmt.Errorf("Not a error data: %V", data)
return
}
err = errors.New(fmt.Sprintf("%s: %s", rel[0], rel[1]))
return
}
// An error handler
type ErrorHandler func(error)