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

Add more context in codegen panic message #611

Merged
merged 1 commit into from
Jul 18, 2019
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
16 changes: 8 additions & 8 deletions codegen/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -1058,14 +1058,14 @@ func getQueryMethodForType(typeSpec compile.TypeSpec) string {
queryMethod = "GetQueryValues"
default:
panic(fmt.Sprintf(
"Unsupported list value type (%T) %v for query string parameter",
t.ValueSpec, t.ValueSpec,
"Unsupported list value type (%T) for %s as query string parameter",
t.ValueSpec, t.ValueSpec.ThriftName(),
))
}
default:
panic(fmt.Sprintf(
"Unknown type (%T) %v for query string parameter",
typeSpec, typeSpec,
"Unsupported type (%T) for %s as query string parameter",
typeSpec, typeSpec.ThriftName(),
))
}

Expand Down Expand Up @@ -1147,14 +1147,14 @@ func getQueryEncodeExpression(
}
default:
panic(fmt.Sprintf(
"Unsupported list value type (%T) %v for query string parameter",
t.ValueSpec, t.ValueSpec,
"Unsupported list value type (%T) for %s as query string parameter",
t.ValueSpec, t.ValueSpec.ThriftName(),
))
}
default:
panic(fmt.Sprintf(
"Unknown type (%T) %v for query string parameter",
typeSpec, typeSpec,
"Unsupported type (%T) for %s as query string parameter",
typeSpec, typeSpec.ThriftName(),
))
}

Expand Down
6 changes: 3 additions & 3 deletions codegen/thrift.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func GoType(p PackageNameResolver, spec compile.TypeSpec) (string, error) {
case *compile.EnumSpec, *compile.StructSpec, *compile.TypedefSpec:
return goCustomType(p, spec)
default:
panic(fmt.Sprintf("Unknown type (%T) %v", spec, spec))
panic(fmt.Sprintf("Unknown type (%T) for %s", spec, spec.ThriftName()))
}
}

Expand Down Expand Up @@ -156,8 +156,8 @@ func pointerMethodType(typeSpec compile.TypeSpec) string {
pointerMethod = "Int32"
default:
panic(fmt.Sprintf(
"Unknown type (%T) %v for allocating a pointer",
typeSpec, typeSpec,
"Unknown type (%T) for %s for allocating a pointer",
typeSpec, typeSpec.ThriftName(),
))
}

Expand Down
2 changes: 1 addition & 1 deletion codegen/thrift_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (f *fakePackageNameResover) TypePackageName(string) (string, error) {
func TestGoTypeUnknownType(t *testing.T) {
s := &fakeSpec{}
p := &fakePackageNameResover{}
assert.PanicsWithValue(t, "Unknown type (*codegen_test.fakeSpec) &{}", func() {
assert.PanicsWithValue(t, "Unknown type (*codegen_test.fakeSpec) for fake", func() {
_, _ = codegen.GoType(p, s)
})

Expand Down