mirror of
https://github.com/rancher/norman.git
synced 2025-09-09 11:09:59 +00:00
status => Status
This commit is contained in:
@@ -32,11 +32,11 @@ var (
|
|||||||
|
|
||||||
type ErrorCode struct {
|
type ErrorCode struct {
|
||||||
code string
|
code string
|
||||||
status int
|
Status int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e ErrorCode) String() string {
|
func (e ErrorCode) String() string {
|
||||||
return fmt.Sprintf("%s %d", e.code, e.status)
|
return fmt.Sprintf("%s %d", e.code, e.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
type APIError struct {
|
type APIError struct {
|
||||||
@@ -49,7 +49,7 @@ type APIError struct {
|
|||||||
func NewAPIErrorLong(status int, code, message string) error {
|
func NewAPIErrorLong(status int, code, message string) error {
|
||||||
return NewAPIError(ErrorCode{
|
return NewAPIError(ErrorCode{
|
||||||
code: code,
|
code: code,
|
||||||
status: status,
|
Status: status,
|
||||||
}, message)
|
}, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,13 +18,13 @@ func ErrorHandler(request *types.APIContext, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
data := toError(error)
|
data := toError(error)
|
||||||
request.WriteResponse(error.code.status, data)
|
request.WriteResponse(error.code.Status, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func toError(apiError *APIError) map[string]interface{} {
|
func toError(apiError *APIError) map[string]interface{} {
|
||||||
e := map[string]interface{}{
|
e := map[string]interface{}{
|
||||||
"type": "/meta/schemas/error",
|
"type": "/meta/schemas/error",
|
||||||
"status": apiError.code.status,
|
"status": apiError.code.Status,
|
||||||
"code": apiError.code.code,
|
"code": apiError.code.code,
|
||||||
"message": apiError.message,
|
"message": apiError.message,
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user