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
|
2013-12-26 12:32:27 +08:00
|
|
|
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 {
|
2014-03-07 17:21:45 +08:00
|
|
|
err = fmt.Errorf("Not a error data: %v", data)
|
2013-08-30 12:36:57 +08:00
|
|
|
return
|
|
|
|
}
|
2014-03-07 17:20:39 +08:00
|
|
|
err = fmt.Errorf("%s: %s", rel[0], rel[1])
|
2013-08-30 12:36:57 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// An error handler
|
|
|
|
type ErrorHandler func(error)
|