Documentation ¶
Index ¶
- Variables
- func CatchPanic(message string)
- func CheckError(err error)
- func HttpPanic(code ErrCode, message string)
- func NotEmpty(source string, parameter string)
- func NotNil(source interface{}, parameter string)
- func Panic(errStr string)
- func PanicEntityNotFound(message string)
- func PanicErr(status int, code ErrCode, message string)
- func PanicNotFound(message string)
- func PanicUnAuthenticated(message string)
- func PanicUnAuthorized(message string)
- func PanicValidatition(message string)
- func PrintStack() string
- type ErrCode
- type HttpError
- type MultiError
- type ValidationError
- type ValidationResult
Constants ¶
This section is empty.
Variables ¶
View Source
var (
DataNotFoundError = errors.New("data not found")
)
View Source
var ErrPageNotFound = &HttpError{ HttpStatus: http.StatusNotFound, Code: ErrCodePageNotFound, Message: "page not found", }
View Source
var ErrUnAuthenticated = &HttpError{ Message: "user not login", Code: ErrCodeUnAuthenticated, HttpStatus: http.StatusUnauthorized, }
View Source
ErrCodeUnauthorized, HttpStatus: http.StatusUnauthorized, }Message: "permission forbidden", Code:
View Source
var UnhandledError = &HttpError{ Message: "服务器未处理异常", Code: ErrCodeUnknown, HttpStatus: http.StatusInternalServerError, }
Functions ¶
func CatchPanic ¶
func CatchPanic(message string)
func CheckError ¶
func CheckError(err error)
func PanicEntityNotFound ¶
func PanicEntityNotFound(message string)
func PanicNotFound ¶
func PanicNotFound(message string)
func PanicUnAuthenticated ¶
func PanicUnAuthenticated(message string)
func PanicUnAuthorized ¶
func PanicUnAuthorized(message string)
func PanicValidatition ¶
func PanicValidatition(message string)
func PrintStack ¶
func PrintStack() string
Types ¶
type HttpError ¶
type HttpError struct { HttpStatus int `json:"-"` Code ErrCode `json:"code"` Message string `json:"message"` Data any `json:"data"` }
func NewUnknownErr ¶
type MultiError ¶
type MultiError struct {
// contains filtered or unexported fields
}
func Errors ¶
func Errors(message string, errs ...error) *MultiError
func (*MultiError) Add ¶
func (e *MultiError) Add(message string, err error)
func (*MultiError) AddError ¶
func (e *MultiError) AddError(err error)
func (*MultiError) Error ¶
func (e *MultiError) Error() string
func (*MultiError) HasError ¶
func (e *MultiError) HasError() bool
type ValidationError ¶
type ValidationError struct {
ValidationErrors []*ValidationResult
}
func (*ValidationError) Error ¶
func (v *ValidationError) Error() string
type ValidationResult ¶
Click to show internal directories.
Click to hide internal directories.