From 0d3fdd1e304a29be0bd22227a24030a5e7ced2f5 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Wed, 9 Mar 2016 14:37:44 +0100 Subject: [PATCH] mobile/bind: replace panics with errors cgoType panics on types not yet supported by bind. Replace the panics with more appropriate error messages. Change-Id: I0b8609b50de07ca93db13c50654f62ffbd9f25c2 Reviewed-on: https://go-review.googlesource.com/20472 Reviewed-by: Hyang-Ah Hana Kim --- bind/gen.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bind/gen.go b/bind/gen.go index 6bd2e01..1a4aec8 100644 --- a/bind/gen.go +++ b/bind/gen.go @@ -159,7 +159,7 @@ func (g *generator) cgoType(t types.Type) string { case types.String: return "nstring" default: - panic(fmt.Sprintf("unsupported basic type: %s", t)) + g.errorf("unsupported basic type: %s", t) } case *types.Slice: switch e := t.Elem().(type) { @@ -168,21 +168,22 @@ func (g *generator) cgoType(t types.Type) string { case types.Uint8: // Byte. return "nbyteslice" default: - panic(fmt.Sprintf("unsupported slice type: %s", t)) + g.errorf("unsupported slice type: %s", t) } default: - panic(fmt.Sprintf("unsupported slice type: %s", t)) + g.errorf("unsupported slice type: %s", t) } case *types.Pointer: if _, ok := t.Elem().(*types.Named); ok { return g.cgoType(t.Elem()) } - panic(fmt.Sprintf("unsupported pointer to type: %s", t)) + g.errorf("unsupported pointer to type: %s", t) case *types.Named: return "int32_t" default: - panic(fmt.Sprintf("unsupported type: %s", t)) + g.errorf("unsupported type: %s", t) } + return "TODO" } func (g *generator) genInterfaceMethodSignature(m *types.Func, iName string, header bool) {