recover
This commit is contained in:
parent
a980bc5de2
commit
cdfe4fff6c
@ -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()}
|
||||||
|
|
||||||
|
@ -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() {
|
||||||
|
Loading…
Reference in New Issue
Block a user