when call middle.Exception should set w.WriteHeader first
Showing
1 changed file
with
5 additions
and
0 deletions
| ... | @@ -294,6 +294,11 @@ func RegisterErrorHander() { | ... | @@ -294,6 +294,11 @@ func RegisterErrorHander() { |
| 294 | 294 | ||
| 295 | func Exception(errcode string, w http.ResponseWriter, r *http.Request, msg string) { | 295 | func Exception(errcode string, w http.ResponseWriter, r *http.Request, msg string) { |
| 296 | if h, ok := ErrorMaps[errcode]; ok { | 296 | if h, ok := ErrorMaps[errcode]; ok { |
| 297 | isint, err := strconv.Atoi(errcode) | ||
| 298 | if err != nil { | ||
| 299 | isint = 500 | ||
| 300 | } | ||
| 301 | w.WriteHeader(isint) | ||
| 297 | h(w, r) | 302 | h(w, r) |
| 298 | return | 303 | return |
| 299 | } else { | 304 | } else { | ... | ... |
-
Please register or sign in to post a comment