New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Print more info when openapi meet a error #307
Conversation
logs.Error("Failed to get k8s deployment state: %s", err.Error()) | ||
c.AddErrorAndResponse("", http.StatusInternalServerError) | ||
logs.Error("Failed to get k8s deployment state", err.Error()) | ||
c.AddErrorAndResponse("Failed to get k8s deployment state:the specified deployment may not exist in the kubernetes cluster.", http.StatusInternalServerError) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里应该加判断区分错误返回不同的类型,而不是所有的都返回500
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wilhelmguo kubernetes 的错误如何区分错误类型?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logs.Error("Failed to get k8s pod state: %s", err.Error()) | ||
c.AddErrorAndResponse("", http.StatusInternalServerError) | ||
logs.Error("Failed to get k8s pod state", err.Error()) | ||
c.AddErrorAndResponse("Failed to get k8s pod state", http.StatusInternalServerError) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
使用 OpenAPI 的时候,一些时候会输出一些含混不清的错误信息,例如:内部错误 等,这些错误没有明确表明用户在哪个环节出了错误,因此这个 PR 在这方面做了改进。
同时,优化了一些错误的声明方式,使之更加贴近 Go 建议的表达方式。主要在于,定义错误不要首字母大写,和输出错误信息要区别开。