AFAIRE
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.0 KiB

/*
------------------------------------------------------------------------------------------------------------------------
####### kong ####### Copyright (c) 2021-2022 losyme ################################################ MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package context
import (
"forge.chapril.org/losyme/errors"
)
type Error struct {
Status int `json:"status"`
Message string `json:"message"`
}
func (e *Error) Error() string {
return errors.New("response error", "status", e.Status, nil, errors.New(e.Message)).Error()
}
func (c *Context) Error(status int, err error) error {
return &Error{
Status: status,
Message: err.Error(),
}
}
func (c *Context) NewError(status int, message string, kv ...interface{}) error {
return c.Error(status, errors.New(message, kv...))
}
/*
######################################################################################################## @(°_°)@ #######
*/