10
http.go
10
http.go
@@ -116,13 +116,15 @@ func getErrors(service *protogen.Service) map[string]struct{} {
|
||||
}
|
||||
|
||||
func generateServiceErrors(gfile *protogen.GeneratedFile, err *Error) {
|
||||
gfile.P("// Code generated by protoc-gen-micro")
|
||||
gfile.P("package ", err.packageName)
|
||||
gfile.P("import (")
|
||||
gfile.P(`"fmt"`)
|
||||
gfile.P(")")
|
||||
gfile.P()
|
||||
|
||||
gfile.Import(fmtPackage)
|
||||
|
||||
for _, typ := range err.types {
|
||||
gfile.P("func (err *", typ[strings.LastIndex(typ, ".")+1:], ") Error() string {")
|
||||
gfile.P(`return fmt.Sprintf("%#v", err)`)
|
||||
gfile.P(`return `, fmtPackage.Ident("Sprintf"), `("%#v", err)`)
|
||||
gfile.P("}")
|
||||
gfile.P()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user