[MM-25606] Make plugin API errors encodable (#14692)

* Make plugin API errors encodable

* Remove newlines

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Shota Gvinepadze
2020-06-11 16:44:50 +04:00
коммит произвёл GitHub
родитель 11812ae8e4
Коммит 77b468e456
2 изменённых файлов: 5 добавлений и 12 удалений

Просмотреть файл

@@ -278,7 +278,7 @@ func (s *hooksRPCServer) {{.Name}}(args *{{.Name | obscure}}Args, returns *{{.Na
{{.Name}}{{funcStyle .Params}} {{funcStyle .Return}}
}); ok {
{{if .Return}}{{destruct "returns." .Return}} = {{end}}hook.{{.Name}}({{destruct "args." .Params}})
{{if .Return}}{{encodeErrors "returns." .Return}}{{end}}
{{if .Return}}{{encodeErrors "returns." .Return}}{{end -}}
} else {
return encodableError(fmt.Errorf("Hook {{.Name}} called but not implemented."))
}
@@ -310,6 +310,7 @@ func (s *apiRPCServer) {{.Name}}(args *{{.Name | obscure}}Args, returns *{{.Name
{{.Name}}{{funcStyle .Params}} {{funcStyle .Return}}
}); ok {
{{if .Return}}{{destruct "returns." .Return}} = {{end}}hook.{{.Name}}({{destruct "args." .Params}})
{{if .Return}}{{encodeErrors "returns." .Return}}{{end -}}
} else {
return encodableError(fmt.Errorf("API {{.Name}} called but not implemented."))
}