(t *testing.T)
| 46 | } |
| 47 | |
| 48 | func TestBuildAPIError_NilAndZeroCode(t *testing.T) { |
| 49 | if got := errclass.BuildAPIError(nil, errclass.ClassifyContext{}); got != nil { |
| 50 | t.Errorf("nil resp should return nil error, got %v", got) |
| 51 | } |
| 52 | if got := errclass.BuildAPIError(map[string]any{"code": 0, "msg": "ok"}, errclass.ClassifyContext{}); got != nil { |
| 53 | t.Errorf("code=0 should return nil error, got %v", got) |
| 54 | } |
| 55 | // json.Number 0 path (real-world SDK decodes with UseNumber) |
| 56 | resp := map[string]any{"code": json.Number("0"), "msg": "ok"} |
| 57 | if got := errclass.BuildAPIError(resp, errclass.ClassifyContext{}); got != nil { |
| 58 | t.Errorf("json.Number(0) should return nil error, got %v", got) |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | // matchesTypedError reports whether err is the typed-error variant identified by |
| 63 | // wantTyped (e.g. "ValidationError" → *errs.ValidationError). Used by the |
nothing calls this directly
no test coverage detected