summaryrefslogtreecommitdiff
path: root/xgbgen/go_error.go
diff options
context:
space:
mode:
authorAndrew Gallant (Ocelot) <[email protected]>2012-05-05 18:21:48 -0400
committerAndrew Gallant (Ocelot) <[email protected]>2012-05-05 18:21:48 -0400
commit568f1c44fb9489a7f7762e96544f0173b23ec61b (patch)
treef2c8fe01e7b4aeaad77bef220ed997c824f1b144 /xgbgen/go_error.go
parentb8d96bcad34ec397b207dc263f61f7776396db26 (diff)
fixing bugs related mostly to extension handling
Diffstat (limited to 'xgbgen/go_error.go')
-rw-r--r--xgbgen/go_error.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/xgbgen/go_error.go b/xgbgen/go_error.go
index 5a51064..152db8b 100644
--- a/xgbgen/go_error.go
+++ b/xgbgen/go_error.go
@@ -64,11 +64,15 @@ func (e *Error) ImplementsError(c *Context) {
c.Putln("}")
c.Putln("")
c.Putln("func (err %s) BadId() Id {", e.ErrType())
- c.Putln("return Id(err.BadValue)")
+ if c.protocol.Name == "xproto" {
+ c.Putln("return Id(err.BadValue)")
+ } else {
+ c.Putln("return 0")
+ }
c.Putln("}")
c.Putln("")
c.Putln("func (err %s) Error() string {", e.ErrType())
- FieldString(c, e.Fields, e.ErrConst())
+ ErrorFieldString(c, e.Fields, e.ErrConst())
c.Putln("}")
c.Putln("")
}
@@ -119,14 +123,14 @@ func (e *ErrorCopy) ImplementsError(c *Context) {
c.Putln("}")
c.Putln("")
c.Putln("func (err %s) Error() string {", e.ErrType())
- FieldString(c, e.Old.(*Error).Fields, e.ErrConst())
+ ErrorFieldString(c, e.Old.(*Error).Fields, e.ErrConst())
c.Putln("}")
c.Putln("")
}
-// FieldString works for both Error and ErrorCopy. It assembles all of the
+// ErrorFieldString works for both Error and ErrorCopy. It assembles all of the
// fields in an error and formats them into a single string.
-func FieldString(c *Context, fields []Field, errName string) {
+func ErrorFieldString(c *Context, fields []Field, errName string) {
c.Putln("fieldVals := make([]string, 0, %d)", len(fields))
c.Putln("fieldVals = append(fieldVals, \"NiceName: \" + err.NiceName)")
c.Putln("fieldVals = append(fieldVals, " +