THRIFT-2854 Go Struct writer and reader looses important error information
Client: Go
Patch: Chi Vinh Le <cvl@chinet.info>

This closes #291

Fixes error reporting in go generator
diff --git a/lib/go/thrift/exception.go b/lib/go/thrift/exception.go
index e08ffc0..4afcefd 100644
--- a/lib/go/thrift/exception.go
+++ b/lib/go/thrift/exception.go
@@ -19,7 +19,26 @@
 
 package thrift
 
+import (
+	"errors"
+)
+
 // Generic Thrift exception
 type TException interface {
 	error
 }
+
+// Prepends additional information to an error without loosing the Thrift exception interface
+func PrependError(prepend string, err error) error {
+	if t, ok := err.(TTransportException); ok {
+		return NewTTransportException(t.TypeId(), prepend+t.Error())
+	}
+	if t, ok := err.(TProtocolException); ok {
+		return NewTProtocolExceptionWithType(t.TypeId(), errors.New(prepend+err.Error()))
+	}
+	if t, ok := err.(TApplicationException); ok {
+		return NewTApplicationException(t.TypeId(), prepend+t.Error())
+	}
+
+	return errors.New(prepend + err.Error())
+}