Skip to content

Commit

Permalink
Slightly improve error code handling
Browse files Browse the repository at this point in the history
When there was an unknown response code there was no debugging info,
but now it logs.
  • Loading branch information
karmanyaahm committed Jul 8, 2021
1 parent b57164b commit 978823e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gateway/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (Matrix) Resp(r []*http.Response, w http.ResponseWriter) {
}{}
rejects.Rej = make([]string, 0)
for _, i := range r {
if i != nil && i.StatusCode == 404 {
if i != nil && i.StatusCode > 400 && i.StatusCode <= 404 {
rejects.Rej = append(rejects.Rej, i.Request.URL.String())
}
}
Expand Down
7 changes: 6 additions & 1 deletion rewrite/gotify.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,17 @@ func (g Gotify) Req(body []byte, req http.Request) (*http.Request, error) {

func (g Gotify) RespCode(resp *http.Response) int {
//convert gotify message response to up resp
return map[int]int{
code, ok := map[int]int{
401: 404,
403: 404,
400: 502, //unknown how to handle gotify 400 TODO
200: 202,
}[resp.StatusCode]
if !ok {
log.Println("Gotify response unknown code", resp.StatusCode)
return 500
}
return code
}

func (g *Gotify) Defaults() (failed bool) {
Expand Down

0 comments on commit 978823e

Please sign in to comment.