Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve error handling #105

Merged
merged 1 commit into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions q_atm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ func TestAtm(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalAtm(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && testcase.err1.Error() == err1.Error() {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := Atm{}
err2 := unmarshalAtm(data, &val)
if err2 != nil {
if testcase.err2 != nil && testcase.err2.Error() == err2.Error() {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_cake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestCake(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalCake(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && testcase.err1.Error() == err1.Error() {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
Expand All @@ -47,7 +47,7 @@ func TestCake(t *testing.T) {
val := Cake{}
err2 := unmarshalCake(newData, &val)
if err2 != nil {
if testcase.err2 != nil && testcase.err2.Error() == err2.Error() {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_cbq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ func TestCbq(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalCbq(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && testcase.err1.Error() == err1.Error() {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := Cbq{}
err2 := unmarshalCbq(data, &val)
if err2 != nil {
if testcase.err2 != nil && testcase.err2.Error() == err2.Error() {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_choke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ func TestChoke(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalChoke(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && testcase.err1.Error() == err1.Error() {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := Choke{}
err2 := unmarshalChoke(data, &val)
if err2 != nil {
if testcase.err2 != nil && testcase.err2.Error() == err2.Error() {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_codel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ func TestCode(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalCodel(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && testcase.err1.Error() == err1.Error() {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := Codel{}
err2 := unmarshalCodel(data, &val)
if err2 != nil {
if testcase.err2 != nil && testcase.err2.Error() == err2.Error() {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_drr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ func TestDrr(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalDrr(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && testcase.err1.Error() == err1.Error() {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := Drr{}
err2 := unmarshalDrr(data, &val)
if err2 != nil {
if testcase.err2 != nil && testcase.err2.Error() == err2.Error() {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_dsmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ func TestDsmark(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalDsmark(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && testcase.err1.Error() == err1.Error() {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := Dsmark{}
err2 := unmarshalDsmark(data, &val)
if err2 != nil {
if testcase.err2 != nil && testcase.err2.Error() == err2.Error() {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_ets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ func TestEts(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalEts(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && testcase.err1.Error() == err1.Error() {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := Ets{}
err2 := unmarshalEts(data, &val)
if err2 != nil {
if testcase.err2 != nil && testcase.err2.Error() == err2.Error() {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_fqCodel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ func TestFqCodel(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalFqCodel(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && testcase.err1.Error() == err1.Error() {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := FqCodel{}
err2 := unmarshalFqCodel(data, &val)
if err2 != nil {
if testcase.err2 != nil && testcase.err2.Error() == err2.Error() {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_fq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ func TestFq(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalFq(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && testcase.err1.Error() == err1.Error() {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := Fq{}
err2 := unmarshalFq(data, &val)
if err2 != nil {
if testcase.err2 != nil && testcase.err2.Error() == err2.Error() {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_hfsc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ func TestHfsc(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalHfsc(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && testcase.err1.Error() == err1.Error() {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := Hfsc{}
err2 := unmarshalHfsc(data, &val)
if err2 != nil {
if testcase.err2 != nil && testcase.err2.Error() == err2.Error() {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_hhf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ func TestHhf(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalHhf(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && testcase.err1.Error() == err1.Error() {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := Hhf{}
err2 := unmarshalHhf(data, &val)
if err2 != nil {
if testcase.err2 != nil && testcase.err2.Error() == err2.Error() {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_htb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestHtb(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalHtb(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && testcase.err1.Error() == err1.Error() {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
Expand All @@ -30,7 +30,7 @@ func TestHtb(t *testing.T) {
val := Htb{}
err2 := unmarshalHtb(newData, &val)
if err2 != nil {
if testcase.err2 != nil && testcase.err2.Error() == err2.Error() {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_mqPrio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ func TestMqPrio(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalMqPrio(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && testcase.err1.Error() == err1.Error() {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := MqPrio{}
err2 := unmarshalMqPrio(data, &val)
if err2 != nil {
if testcase.err2 != nil && testcase.err2.Error() == err2.Error() {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_netem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ func TestNetem(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalNetem(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && testcase.err1.Error() == err1.Error() {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := Netem{}
err2 := unmarshalNetem(data, &val)
if err2 != nil {
if testcase.err2 != nil && testcase.err2.Error() == err2.Error() {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_pie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ func TestPie(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalPie(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && testcase.err1.Error() == err1.Error() {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := Pie{}
err2 := unmarshalPie(data, &val)
if err2 != nil {
if testcase.err2 != nil && testcase.err2.Error() == err2.Error() {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_prio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ func TestPrio(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalPrio(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && errors.Is(err1, testcase.err1) {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := Prio{}
err2 := unmarshalPrio(data, &val)
if err2 != nil {
if testcase.err2 != nil && errors.Is(err2, testcase.err2) {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_qfq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ func TestQfq(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalQfq(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && testcase.err1.Error() == err1.Error() {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := Qfq{}
err2 := unmarshalQfq(data, &val)
if err2 != nil {
if testcase.err2 != nil && testcase.err2.Error() == err2.Error() {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_red_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ func TestRed(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalRed(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && testcase.err1.Error() == err1.Error() {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := Red{}
err2 := unmarshalRed(data, &val)
if err2 != nil {
if testcase.err2 != nil && testcase.err2.Error() == err2.Error() {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_sfb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ func TestSfb(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalSfb(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && errors.Is(err1, testcase.err1) {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := Sfb{}
err2 := unmarshalSfb(data, &val)
if err2 != nil {
if testcase.err2 != nil && errors.Is(err2, testcase.err2) {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down
4 changes: 2 additions & 2 deletions q_sfq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ func TestSfq(t *testing.T) {
t.Run(name, func(t *testing.T) {
data, err1 := marshalSfq(&testcase.val)
if err1 != nil {
if testcase.err1 != nil && errors.Is(err1, testcase.err1) {
if errors.Is(err1, testcase.err1) {
return
}
t.Fatalf("Unexpected error: %v", err1)
}
val := Sfq{}
err2 := unmarshalSfq(data, &val)
if err2 != nil {
if testcase.err2 != nil && errors.Is(err2, testcase.err2) {
if errors.Is(err2, testcase.err2) {
return
}
t.Fatalf("Unexpected error: %v", err2)
Expand Down