1
0
mirror of https://github.com/gluster/glusterd2.git synced 2026-02-07 09:46:04 +01:00
Files
glusterd2/pkg/api/errors.go
Prashanth Pai 681c6b8987 Set generic error code to 1, not 0
...as 0 can indicate success.

* Added a comment with usage example for SendHTTPError()
* Handled case of passing nil:
    SendHTTPError(ctx, http.StatusBadRequest, nil, api.SomeErrorCode)

Signed-off-by: Prashanth Pai <ppai@redhat.com>
2018-03-22 14:44:26 +05:30

27 lines
667 B
Go

package api
// HTTPError contains an error code and corresponding text which briefly
// describes the error in short.
type HTTPError struct {
Code int `json:"code"`
Message string `json:"message"`
}
// ErrorResp is an error response which may contain one or more error responses
type ErrorResp struct {
Errors []HTTPError `json:"errors"`
}
// ErrorCode represents API Error code Type
type ErrorCode uint16
const (
// ErrCodeGeneric represents generic error code for API responses
ErrCodeGeneric ErrorCode = iota + 1
)
// ErrorCodeMap maps error code to it's textual message
var ErrorCodeMap = map[ErrorCode]string{
ErrCodeGeneric: "generic error",
}