1
0
mirror of https://github.com/gluster/glusterd2.git synced 2026-02-05 12:45:38 +01:00
Files
glusterd2/pkg/api/errors.go
Prashanth Pai 7b84ef8757 txn: Add CLI support to parse txn error
Signed-off-by: Prashanth Pai <ppai@redhat.com>
2018-06-06 21:37:02 +05:30

40 lines
1.1 KiB
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"`
Fields map[string]string `json:"fields,omitempty"`
}
// 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
// ErrTxnStepFailed represents failure of a txn step
ErrTxnStepFailed
)
// ErrorCodeMap maps error code to it's textual message
var ErrorCodeMap = map[ErrorCode]string{
ErrCodeGeneric: "generic error",
ErrTxnStepFailed: "a txn step failed",
}
// ErrorResponse is an interface that types can implement on custom errors.
type ErrorResponse interface {
error
// Response returns the error response to be returned to client.
Response() ErrorResp
// Status returns the HTTP status code to be returned to client.
Status() int
}