mirror of
https://github.com/gluster/glusterd2.git
synced 2026-02-07 09:46:04 +01:00
...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>
27 lines
667 B
Go
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",
|
|
}
|