Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrPrefix ¶
type ErrPrefix string
ErrPrefix is a string that can be used to prefix an error message.
func (ErrPrefix) ErrorIf ¶
ErrorIf returns a error with prefix if the error is not nil, otherwise it returns nil.
func (ErrPrefix) ErrorMap ¶
ErrorMap is used to unwrap result from a function that returns a byte slice and an error. If the error is not nil, it returns the error with prefix, otherwise it returns the byte slice.
type Error ¶ added in v0.1.0
type Error struct { Code int `json:"code" cbor:"code"` Message string `json:"message" cbor:"message"` Data any `json:"data,omitempty" cbor:"data,omitempty"` // contains filtered or unexported fields }
Error represents a error with more information, can be used as response error.
func (*Error) CatchIf ¶ added in v0.1.0
CatchIf catches the error and return true if the error is not nil.
func (*Error) Error ¶ added in v0.1.0
Error returns the full error information as a JSON string, used as error log.
type RespondError ¶ added in v0.1.0
type RespondError struct {
Err any `json:"error" cbor:"error"`
}
RespondError represents a response with error that can be sent to the client.