xerrors

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2025 License: MIT Imports: 3 Imported by: 2

Documentation

Overview

Package xerrors provides standardized error types and error handling utilities for application-specific errors, including API, database, and routing errors.

Index

Constants

This section is empty.

Variables

View Source
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")
)
View Source
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

View Source
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

View Source
var (
	// ErrRouteTableNotFound is returned when a requested route table entry cannot be found.
	ErrRouteTableNotFound = errors.New("route table not found")
)

Route table errors

View Source
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

func APIAlreadyExists(message string, a ...any) *errors.Error

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

func APIAuthFailed(message string, a ...any) *errors.Error

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

func APICodecFailed(message string, a ...any) *errors.Error

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

func APIDBFailed(message string, a ...any) *errors.Error

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

func APIDBNoAffected(message string, a ...any) *errors.Error

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

func APINotFound(message string, a ...any) *errors.Error

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

func APIPageParamInvalid(message string, a ...any) *errors.Error

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

func APIParamInvalid(message string, a ...any) *errors.Error

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

func APIPlatformAuthFailed(message string, a ...any) *errors.Error

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

func APISessionIllegal(message string, a ...any) *errors.Error

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

func APISessionTimeout(message string, a ...any) *errors.Error

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

func APIStateUpdateFailed(message string, a ...any) *errors.Error

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

func APIStatusIllegal(message string, a ...any) *errors.Error

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

func IsLogoutError(err error) bool

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL