Documentation
¶
Index ¶
- func IsServerError(err error) bool
- func WithCause(err error) func(*LogicError)
- type LogicError
- func New400LogicError(lang string, messageID string, tplData ...any) *LogicError
- func New401LogicError(lang string, messageID string, tplData ...any) *LogicError
- func New403LogicError(lang string, messageID string, tplData ...any) *LogicError
- func New404LogicError(lang string, messageID string, tplData ...any) *LogicError
- func New500LogicError(lang string, messageID string, tplData ...any) *LogicError
- func NewLogicErr(code int16, lang string, messageID string, tplData ...any) *LogicError
- func NewRawLogicErr(code int16, message string, opts ...func(*LogicError)) *LogicError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsServerError ¶
IsServerError checks if the error represents a server-side issue (HTTP 5xx)
func WithCause ¶ added in v0.13.0
func WithCause(err error) func(*LogicError)
Types ¶
type LogicError ¶
type LogicError struct {
// contains filtered or unexported fields
}
LogicError represents a business logic error with code mapping and localization support
func New400LogicError ¶
func New400LogicError(lang string, messageID string, tplData ...any) *LogicError
New400LogicError creates Bad Request error (HTTP 400) Typically indicates invalid request parameters or malformed input
func New401LogicError ¶
func New401LogicError(lang string, messageID string, tplData ...any) *LogicError
New401LogicError creates Unauthorized error (HTTP 401) Indicates missing or invalid authentication credentials
func New403LogicError ¶
func New403LogicError(lang string, messageID string, tplData ...any) *LogicError
New403LogicError creates Forbidden error (HTTP 403) The client lacks sufficient permissions for the requested operation
func New404LogicError ¶
func New404LogicError(lang string, messageID string, tplData ...any) *LogicError
New404LogicError creates Not Found error (HTTP 404) Specified resource does not exist in the system
func New500LogicError ¶
func New500LogicError(lang string, messageID string, tplData ...any) *LogicError
New500LogicError creates Internal Server Error (HTTP 500) Reserved for unexpected server-side failures
func NewLogicErr ¶
func NewLogicErr(code int16, lang string, messageID string, tplData ...any) *LogicError
NewLogicErr creates a localized business error using i18n message ID
func NewRawLogicErr ¶
func NewRawLogicErr(code int16, message string, opts ...func(*LogicError)) *LogicError
NewRawLogicErr creates a business error with raw message (non-localized)
func (LogicError) Code ¶
func (e LogicError) Code() int16
Code returns the HTTP status code mapped to this business error
func (LogicError) Error ¶
func (e LogicError) Error() string
Error implements error interface with formatted error details
func (*LogicError) GetCause ¶ added in v0.13.0
func (e *LogicError) GetCause() error
GetCause retrieves the underlying error that triggered this business error
func (LogicError) Message ¶
func (e LogicError) Message() string
Message returns the localized error message for client presentation
func (*LogicError) SetCause ¶ added in v0.13.0
func (e *LogicError) SetCause(err error) *LogicError
SetCause attaches the root cause error for debugging purposes