error: don't include path in HTTP errors
Some checks failed
Go / Lint (latest) (push) Has been cancelled
Go / Build (old, libolm) (push) Has been cancelled
Go / Build (latest, libolm) (push) Has been cancelled
Go / Build (old, goolm) (push) Has been cancelled
Go / Build (latest, goolm) (push) Has been cancelled

The request data is logged anyway, so it's nicer if the error string
only has the important part.
This commit is contained in:
Tulir Asokan 2024-12-19 23:33:56 +02:00
commit 918ed4bf23

View file

@ -96,10 +96,9 @@ func (e HTTPError) Error() string {
if e.WrappedError != nil {
return fmt.Sprintf("%s: %v", e.Message, e.WrappedError)
} else if e.RespError != nil {
return fmt.Sprintf("failed to %s %s: %s (HTTP %d): %s", e.Request.Method, e.Request.URL.Path,
e.RespError.ErrCode, e.Response.StatusCode, e.RespError.Err)
return fmt.Sprintf("%s (HTTP %d): %s", e.RespError.ErrCode, e.Response.StatusCode, e.RespError.Err)
} else {
msg := fmt.Sprintf("failed to %s %s: HTTP %d", e.Request.Method, e.Request.URL.Path, e.Response.StatusCode)
msg := fmt.Sprintf("HTTP %d", e.Response.StatusCode)
if len(e.ResponseBody) > 0 {
msg = fmt.Sprintf("%s: %s", msg, e.ResponseBody)
}