Documentation
¶
Overview ¶
Package xerrors provides standardized error types and error handling utilities for application-specific errors, including API, database, and routing errors.
Index ¶
- Variables
- func APIAlreadyExists(message string, a ...any) *errors.Error
- func APIAuthFailed(message string, a ...any) *errors.Error
- func APICodecFailed(message string, a ...any) *errors.Error
- func APIDBFailed(message string, a ...any) *errors.Error
- func APIDBNoAffected(message string, a ...any) *errors.Error
- func APINotFound(message string, a ...any) *errors.Error
- func APIPageParamInvalid(message string, a ...any) *errors.Error
- func APIParamInvalid(message string, a ...any) *errors.Error
- func APIPlatformAuthFailed(message string, a ...any) *errors.Error
- func APISessionIllegal(message string, a ...any) *errors.Error
- func APISessionTimeout(message string, a ...any) *errors.Error
- func APIStateUpdateFailed(message string, a ...any) *errors.Error
- func APIStatusIllegal(message string, a ...any) *errors.Error
- func IsLogoutError(err error) bool
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAPIStatusIllegal is a predefined error for illegal status conditions. ErrAPIStatusIllegal = APIStatusIllegal("default status illegal") // ErrAPIParamInvalid is a predefined error for invalid parameters. ErrAPIParamInvalid = APIParamInvalid("default param invalid") // ErrAPIPageParamInvalid is a predefined error for invalid pagination parameters. ErrAPIPageParamInvalid = APIPageParamInvalid("default page param invalid") // ErrAPINotFound is a predefined error for resources that cannot be found. ErrAPINotFound = APINotFound("default not found") // ErrAPIAlreadyExists is a predefined error for resources that already exist. ErrAPIAlreadyExists = APIAlreadyExists("default already exists") // ErrAPIStateUpdateFailed is a predefined error for state update failures. ErrAPIStateUpdateFailed = APIStateUpdateFailed("default state update failed") // ErrAPISessionIllegal is a predefined error for illegal session conditions. ErrAPISessionIllegal = APISessionIllegal("default session illegal") // ErrAPISessionTimeout is a predefined error for session timeouts. ErrAPISessionTimeout = APISessionTimeout("default session timeout") // ErrAPIAuthFailed is a predefined error for authentication failures. ErrAPIAuthFailed = APIAuthFailed("default auth failed") // ErrAPIPlatformAuthFailed is a predefined error for platform authentication failures. ErrAPIPlatformAuthFailed = APIPlatformAuthFailed("default platform auth failed") // ErrAPICodecFailed is a predefined error for codec failures. ErrAPICodecFailed = APICodecFailed("default codec failed") // ErrAPIDBFailed is a predefined error for database operation failures. ErrAPIDBFailed = APIDBFailed("default db failed") // ErrAPIDBNoAffected is a predefined error for database operations that didn't affect any records. ErrAPIDBNoAffected = APIDBFailed("default db no affected") )
var ( // ErrDBRecordNotFound is returned when a requested database record does not exist. ErrDBRecordNotFound = errors.New("record not found") // ErrDBRecordExists is returned when attempting to create a record that already exists. ErrDBRecordExists = errors.New("record exists") // ErrDBRecordVersion is returned when there's a version conflict in optimistic locking. ErrDBRecordVersion = errors.New("record version error") // ErrDBRecordNotAffected is returned when a database update operation didn't affect any records. ErrDBRecordNotAffected = errors.New("record update error") // ErrDBRecordType is returned when there's a type mismatch in database operations. ErrDBRecordType = errors.New("record type error") // ErrDBProtoEncode is returned when protobuf encoding fails for a database record. ErrDBProtoEncode = errors.New("db proto encode error") // ErrDBProtoDecode is returned when protobuf decoding fails for a database record. ErrDBProtoDecode = errors.New("db proto decode error") )
DB errors
var ( // ErrLogoutFromUser is returned when a user actively logs out. ErrLogoutFromUser = errors.New("user logout") // ErrLogoutBanned is returned when a user is banned from the service. ErrLogoutBanned = errors.New("banned") // ErrLogoutKickOut is returned when a user is forcibly disconnected. ErrLogoutKickOut = errors.New("kick out") // ErrLogoutConflictingLogin is returned when the same user logs in from another location. ErrLogoutConflictingLogin = errors.New("conflicting login") // ErrLogoutMainTunnelClosed is returned when the main communication tunnel is closed. ErrLogoutMainTunnelClosed = errors.New("main tunnel closed") )
User logout errors
var ( // ErrRouteTableNotFound is returned when a requested route table entry cannot be found. ErrRouteTableNotFound = errors.New("route table not found") )
Route table errors
var ( // ErrTunnelStopped is returned when operations are attempted on a stopped tunnel. ErrTunnelStopped = errors.New("tunnel stopped") )
Tunnel errors
Functions ¶
func APIAlreadyExists ¶ added in v0.0.6
APIAlreadyExists creates a conflict error with an "ALREADY_EXISTS" reason code. The message can include format specifiers that will be replaced by the provided arguments.
func APIAuthFailed ¶ added in v0.0.6
APIAuthFailed creates an unauthorized error with an "AUTH_FAILED" reason code. The message can include format specifiers that will be replaced by the provided arguments.
func APICodecFailed ¶ added in v0.0.6
APICodecFailed creates an internal server error with a "CODEC_FAILED" reason code. The message can include format specifiers that will be replaced by the provided arguments.
func APIDBFailed ¶ added in v0.0.6
APIDBFailed creates an internal server error with a "DB_FAILED" reason code. The message can include format specifiers that will be replaced by the provided arguments.
func APIDBNoAffected ¶ added in v0.0.6
APIDBNoAffected creates a conflict error with a "DB_NO_AFFECTED" reason code. The message can include format specifiers that will be replaced by the provided arguments.
func APINotFound ¶ added in v0.0.6
APINotFound creates a not found error with a "NOT_FOUND" reason code. The message can include format specifiers that will be replaced by the provided arguments.
func APIPageParamInvalid ¶ added in v0.0.6
APIPageParamInvalid creates a bad request error with a "PAGE_PARAM_INVALID" reason code. The message can include format specifiers that will be replaced by the provided arguments.
func APIParamInvalid ¶ added in v0.0.6
APIParamInvalid creates a bad request error with a "PARAM_INVALID" reason code. The message can include format specifiers that will be replaced by the provided arguments.
func APIPlatformAuthFailed ¶ added in v0.0.6
APIPlatformAuthFailed creates an unauthorized error with a "PLATFORM_AUTH_FAILED" reason code. The message can include format specifiers that will be replaced by the provided arguments.
func APISessionIllegal ¶ added in v0.0.6
APISessionIllegal creates an unauthorized error with a "SESSION_ILLEGAL" reason code. The message can include format specifiers that will be replaced by the provided arguments.
func APISessionTimeout ¶ added in v0.0.6
APISessionTimeout creates an unauthorized error with a "SESSION_TIMEOUT" reason code. The message can include format specifiers that will be replaced by the provided arguments.
func APIStateUpdateFailed ¶ added in v0.0.6
APIStateUpdateFailed creates a conflict error with a "STATE_UPDATE_FAILED" reason code. The message can include format specifiers that will be replaced by the provided arguments.
func APIStatusIllegal ¶ added in v0.0.6
APIStatusIllegal creates a forbidden error with a "STATUS_ILLEGAL" reason code. The message can include format specifiers that will be replaced by the provided arguments.
func IsLogoutError ¶ added in v0.0.4
IsLogoutError checks if the provided error is any type of logout error. Returns true if the error is one of the predefined logout errors.
Types ¶
This section is empty.