[MM-25606] Make plugin API errors encodable (#14692)
* Make plugin API errors encodable * Remove newlines Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
11812ae8e4
Коммит
77b468e456
@@ -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."))
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user