2
0
mirror of https://github.com/hibiken/asynq.git synced 2026-07-02 10:50:50 +08:00

Revert "feat (add): panic error handling (#491)"

This reverts commit 551b0c7119.
This commit is contained in:
Ken Hibino
2023-07-20 07:08:49 -07:00
committed by GitHub
parent 2165ed133b
commit fd08c06232
5 changed files with 3 additions and 85 deletions

View File

@@ -9,7 +9,6 @@ import (
"encoding/json"
"fmt"
"sort"
"strings"
"sync"
"testing"
"time"
@@ -922,45 +921,3 @@ func TestProcessorComputeDeadline(t *testing.T) {
}
}
}
func TestReturnPanicError(t *testing.T) {
task := NewTask("gen_thumbnail", h.JSON(map[string]interface{}{"src": "some/img/path"}))
tests := []struct {
name string
handler HandlerFunc
IsPanicError bool
}{
{
name: "should return panic error when occurred panic recovery",
handler: func(ctx context.Context, t *Task) error {
panic("something went terribly wrong")
},
IsPanicError: true,
},
{
name: "should return normal error when don't occur panic recovery",
handler: func(ctx context.Context, t *Task) error {
return fmt.Errorf("something went terribly wrong")
},
IsPanicError: false,
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
p := processor{
logger: log.NewLogger(nil),
handler: tc.handler,
}
got := p.perform(context.Background(), task)
if tc.IsPanicError != IsPanicError(got) {
t.Errorf("%s: got=%t, want=%t", tc.name, IsPanicError(got), tc.IsPanicError)
}
if tc.IsPanicError && !strings.HasPrefix(got.Error(), "panic error cause by:") {
t.Error("wrong text msg for panic error")
}
})
}
}