Skip to content

Commit

Permalink
Merge pull request #611 from uber/argo/more_descriptive_errors
Browse files Browse the repository at this point in the history
Add more context in codegen panic message
  • Loading branch information
argouber committed Jul 18, 2019
2 parents 8eac3ef + b94364d commit 2f46873
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
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

0 comments on commit 2f46873

Please sign in to comment.