Documentation ¶
Index ¶
- Constants
- Variables
- func CustomWrap(err error, args ...string) error
- func CustomWrapF(err error, flag string, args ...string) error
- type ErrorFormat
- type ErrorMessage
- func NewErrorMessage() *ErrorMessage
- func SetDefaultNewBadRequest() *ErrorMessage
- func SetDefaultUnauthorized() *ErrorMessage
- func SetNewBadRequest(errorName, errDesc string) *ErrorMessage
- func SetNewBadRequestByFormat(ef *ErrorFormat) *ErrorMessage
- func SetNewError(code int, errorName, errDesc string) *ErrorMessage
- func SetNewInternalError() *ErrorMessage
- func SetNewUnauthorizedError(errorName, errDesc string) *ErrorMessage
- func (errorMessage *ErrorMessage) Append(errorName, errDesc string) *ErrorMessage
- func (errorMessage *ErrorMessage) AppendFormat(ef *ErrorFormat) *ErrorMessage
- func (errorMessage *ErrorMessage) Error() string
- func (errorMessage *ErrorMessage) GetCode() int
- func (errorMessage *ErrorMessage) GetListError() []*ErrorFormat
- func (errorMessage *ErrorMessage) Marshal() []byte
- func (em *ErrorMessage) SetBadRequest() *ErrorMessage
- func (errorMessage *ErrorMessage) ToString() string
Constants ¶
const ( //ErrInternalServer type internal server error ErrInternalServer = 0 //ErrBadRequest error type bad request ErrBadRequest = 1 )
const ( InternalServerName = "internal_server_error" InternalServerDescription = "The server is unable to complete your request" )
Common internal server error message
const ()
Common error unautorized
Variables ¶
var ( ErrKeyExists = errors.New("Key already exists") ErrKeyNotFound = errors.New("Key not found") ErrKeyDuplicate = errors.New("Key already exists") )
error list
var DefaultBadRequest = ErrorFormat{
ErrorName: "bad_request",
ErrorDescription: "Your request resulted in error",
}
Common bad request error message
var (
ErrCommon = errors.New("A failure occurred")
)
Functions ¶
func CustomWrap ¶
CustomWrap custom error wrap without flag example result : <args> : <err>
Types ¶
type ErrorFormat ¶
type ErrorFormat struct { ErrorName string `json:"error_name"` ErrorDescription string `json:"error_description"` }
An ErrorFormat represents an error message format and code that we used.
type ErrorMessage ¶
type ErrorMessage struct { ErrorList []*ErrorFormat `json:"error_list"` Code int `json:"code"` }
An ErrorMessage represents an error message format and list of error.
func SetDefaultNewBadRequest ¶
func SetDefaultNewBadRequest() *ErrorMessage
func SetDefaultUnauthorized ¶
func SetDefaultUnauthorized() *ErrorMessage
SetNewUnauthorizedError is function return new error message with unauthorized error code(400). It support to set error name and error description
func SetNewBadRequest ¶
func SetNewBadRequest(errorName, errDesc string) *ErrorMessage
SetNewBadRequest is function return new error message with bad request standard code(400). It support to set error name and error description
func SetNewBadRequestByFormat ¶
func SetNewBadRequestByFormat(ef *ErrorFormat) *ErrorMessage
SetNewBadRequest is function return new error message with bad request standard code(400). It support to set error name and error description using error format
func SetNewError ¶
func SetNewError(code int, errorName, errDesc string) *ErrorMessage
SetNewError is function return new error message. It support to set code, error name, and error description
func SetNewInternalError ¶
func SetNewInternalError() *ErrorMessage
SetNewInternalError is function return new error message with internal server error standard code(500).
func SetNewUnauthorizedError ¶
func SetNewUnauthorizedError(errorName, errDesc string) *ErrorMessage
SetNewUnauthorizedError is function return new error message with unauthorized error code(400). It support to set error name and error description
func (*ErrorMessage) Append ¶
func (errorMessage *ErrorMessage) Append(errorName, errDesc string) *ErrorMessage
Append is function add error to existing error message. It support to set error name and error description.
func (*ErrorMessage) AppendFormat ¶
func (errorMessage *ErrorMessage) AppendFormat(ef *ErrorFormat) *ErrorMessage
AppendFormat is function add error to existing error message. It support to set error name and error description using error format
func (*ErrorMessage) Error ¶
func (errorMessage *ErrorMessage) Error() string
Error to implement error interface
func (*ErrorMessage) GetCode ¶
func (errorMessage *ErrorMessage) GetCode() int
GetCode is function to get code.
func (*ErrorMessage) GetListError ¶
func (errorMessage *ErrorMessage) GetListError() []*ErrorFormat
GetListError is function to get list error message.
func (*ErrorMessage) SetBadRequest ¶
func (em *ErrorMessage) SetBadRequest() *ErrorMessage
Set bad request