You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/07/23 08:22:24 UTC
[GitHub] [servicecomb-service-center] little-cui commented on a change in pull request #1103: Add list self permission API
little-cui commented on a change in pull request #1103:
URL: https://github.com/apache/servicecomb-service-center/pull/1103#discussion_r675388008
##########
File path: pkg/rest/util.go
##########
@@ -35,13 +35,18 @@ var errNilRequestBody = errors.New("request body is nil")
func WriteError(w http.ResponseWriter, code int32, detail string) {
err := discovery.NewError(code, detail)
- WriteErrsvcError(w, err)
+ WriteServiceError(w, err)
}
-func WriteErrsvcError(w http.ResponseWriter, err *errsvc.Error) {
+func WriteServiceError(w http.ResponseWriter, err error) {
+ e, ok := err.(*errsvc.Error)
+ if !ok {
+ WriteError(w, discovery.ErrInternal, err.Error())
+ return
+ }
w.Header().Set(HeaderContentType, ContentTypeJSON)
- w.WriteHeader(err.StatusCode())
- b, _ := json.Marshal(err)
+ w.WriteHeader(e.StatusCode())
+ b, _ := json.Marshal(e)
_, _ = w.Write(b)
Review comment:
DONE
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org