recover
This commit is contained in:
parent
a980bc5de2
commit
cdfe4fff6c
@ -25,6 +25,7 @@ var (
|
||||
ErrConnection = errors.New("Connection error.")
|
||||
ErrNoActiveAgent = errors.New("No active agent.")
|
||||
ErrExecTimeOut = errors.New("Executing time out.")
|
||||
ErrUnknown = errors.New("Unknown error.")
|
||||
)
|
||||
func DisablePanic() {recover()}
|
||||
|
||||
|
@ -237,6 +237,15 @@ func (worker *Worker) SetId(id string) {
|
||||
|
||||
// Execute the job. And send back the result.
|
||||
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 {
|
||||
<-worker.limit
|
||||
defer func() {
|
||||
|
Loading…
Reference in New Issue
Block a user