mirror of
https://github.com/rancher/norman.git
synced 2025-09-04 16:50:41 +00:00
make url error logging prettier
This commit is contained in:
committed by
Darren Shepherd
parent
bde68141b6
commit
d85dfb2d48
@@ -1,6 +1,8 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/url"
|
||||||
|
|
||||||
"github.com/rancher/norman/httperror"
|
"github.com/rancher/norman/httperror"
|
||||||
"github.com/rancher/norman/types"
|
"github.com/rancher/norman/types"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@@ -10,8 +12,12 @@ func ErrorHandler(request *types.APIContext, err error) {
|
|||||||
var error *httperror.APIError
|
var error *httperror.APIError
|
||||||
if apiError, ok := err.(*httperror.APIError); ok {
|
if apiError, ok := err.(*httperror.APIError); ok {
|
||||||
if apiError.Cause != nil {
|
if apiError.Cause != nil {
|
||||||
|
url, _ := url.PathUnescape(request.Request.URL.String())
|
||||||
|
if url == "" {
|
||||||
|
url = request.Request.URL.String()
|
||||||
|
}
|
||||||
logrus.Errorf("API error response %v for %v %v. Cause: %v", apiError.Code.Status, request.Request.Method,
|
logrus.Errorf("API error response %v for %v %v. Cause: %v", apiError.Code.Status, request.Request.Method,
|
||||||
request.Request.RequestURI, apiError.Cause)
|
url, apiError.Cause)
|
||||||
}
|
}
|
||||||
error = apiError
|
error = apiError
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user