complete fixup

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-02-24 01:19:57 +03:00
parent b2f5437d6e
commit 2dc9459eb8
2 changed files with 62 additions and 60 deletions

10
http.go
View File

@@ -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()
}