check error field in proto message
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
a0385eff9c
commit
558669d292
5
util.go
5
util.go
@ -1002,6 +1002,11 @@ func (g *Generator) writeErrors(plugin *protogen.Plugin) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, field := range msg.Fields {
|
||||||
|
if field.GoName == "Error" {
|
||||||
|
return fmt.Errorf("failed generate Error() string interface for %s message %s already have Error field", field.Location.SourceFile, msg.Desc.Name())
|
||||||
|
}
|
||||||
|
}
|
||||||
gfile.P(`func (m *`, msg.GoIdent.GoName, `) Error() string {`)
|
gfile.P(`func (m *`, msg.GoIdent.GoName, `) Error() string {`)
|
||||||
gfile.P(`buf, _ := marshaler.Marshal(m)`)
|
gfile.P(`buf, _ := marshaler.Marshal(m)`)
|
||||||
gfile.P("return string(buf)")
|
gfile.P("return string(buf)")
|
||||||
|
Loading…
Reference in New Issue
Block a user