Exclude too detailed information from timeout error
This commit is contained in:
parent
3dd28fa028
commit
ca95bf275a
|
@ -5,6 +5,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -603,6 +604,14 @@ func (handler *UnroutedHandler) sendError(w http.ResponseWriter, r *http.Request
|
||||||
err = ErrNotFound
|
err = ErrNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Errors for read timeouts contain too much information which is not
|
||||||
|
// necessary for us and makes grouping for the metrics harder. The error
|
||||||
|
// message looks like: read tcp 127.0.0.1:1080->127.0.0.1:53673: i/o timeout
|
||||||
|
// Therefore, we use a common error message for all of them.
|
||||||
|
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
|
||||||
|
err = errors.New("read tcp: i/o timeout")
|
||||||
|
}
|
||||||
|
|
||||||
status := 500
|
status := 500
|
||||||
if statusErr, ok := err.(HTTPError); ok {
|
if statusErr, ok := err.(HTTPError); ok {
|
||||||
status = statusErr.StatusCode()
|
status = statusErr.StatusCode()
|
||||||
|
|
Loading…
Reference in New Issue