This commit is contained in:
mikespook 2012-06-04 22:27:10 +08:00
parent a980bc5de2
commit cdfe4fff6c
2 changed files with 10 additions and 0 deletions

View File

@ -25,6 +25,7 @@ var (
ErrConnection = errors.New("Connection error.") ErrConnection = errors.New("Connection error.")
ErrNoActiveAgent = errors.New("No active agent.") ErrNoActiveAgent = errors.New("No active agent.")
ErrExecTimeOut = errors.New("Executing time out.") ErrExecTimeOut = errors.New("Executing time out.")
ErrUnknown = errors.New("Unknown error.")
) )
func DisablePanic() {recover()} func DisablePanic() {recover()}

View File

@ -237,6 +237,15 @@ func (worker *Worker) SetId(id string) {
// Execute the job. And send back the result. // Execute the job. And send back the result.
func (worker *Worker) exec(job *Job) (err error) { func (worker *Worker) exec(job *Job) (err error) {
defer func() {
if r := recover(); r != nil {
if e, ok := r.(error); ok {
err = e
} else {
err = common.ErrUnknown
}
}
} ()
if worker.limit != nil { if worker.limit != nil {
<-worker.limit <-worker.limit
defer func() { defer func() {