errors

package
v0.0.0-...-0aebbf4 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppErrorInit

func AppErrorInit(t goi18n.TranslateFunc)

func AuthErrorInit

func AuthErrorInit(t goi18n.TranslateFunc)

func RegisterConstraint

func RegisterConstraint(name, message string)

RegisterConstraint registers custom database check constraints with a custom message.

Types

type AppError

type AppError interface {
	SetTranslationParams(map[string]any) AppError
	GetTranslationParams() map[string]any
	SetStatusCode(int) AppError
	GetStatusCode() int
	SetDetailedError(string)
	GetDetailedError() string
	SetRequestId(string)
	GetRequestId() string
	GetId() string

	Error() string
	Translate(goi18n.TranslateFunc)
	SystemMessage(goi18n.TranslateFunc) string
	ToJson() string
	String() string
}

func NewBadRequestError

func NewBadRequestError(id string, details string) AppError

func NewForbiddenError

func NewForbiddenError(id string, details string) AppError

func NewInternalError

func NewInternalError(id string, details string) AppError

Error constructors

func NewNotFoundError

func NewNotFoundError(id string, details string) AppError

type ApplicationError

type ApplicationError struct {
	Id            string `json:"id"`
	Where         string `json:"where,omitempty"`
	Status        string `json:"status"`
	DetailedError string `json:"detail"`
	RequestId     string `json:"request_id,omitempty"`
	StatusCode    int    `json:"code,omitempty"`
	// contains filtered or unexported fields
}

func (*ApplicationError) Error

func (err *ApplicationError) Error() string

func (*ApplicationError) GetDetailedError

func (err *ApplicationError) GetDetailedError() string

func (*ApplicationError) GetId

func (err *ApplicationError) GetId() string

func (*ApplicationError) GetRequestId

func (err *ApplicationError) GetRequestId() string

func (*ApplicationError) GetStatusCode

func (err *ApplicationError) GetStatusCode() int

func (*ApplicationError) GetTranslationParams

func (err *ApplicationError) GetTranslationParams() map[string]any

func (*ApplicationError) SetDetailedError

func (err *ApplicationError) SetDetailedError(details string)

func (*ApplicationError) SetRequestId

func (err *ApplicationError) SetRequestId(id string)

func (*ApplicationError) SetStatusCode

func (err *ApplicationError) SetStatusCode(code int) AppError

func (*ApplicationError) SetTranslationParams

func (err *ApplicationError) SetTranslationParams(params map[string]any) AppError

func (*ApplicationError) String

func (err *ApplicationError) String() string

func (*ApplicationError) SystemMessage

func (err *ApplicationError) SystemMessage(T goi18n.TranslateFunc) string

func (*ApplicationError) ToJson

func (err *ApplicationError) ToJson() string

func (*ApplicationError) Translate

func (err *ApplicationError) Translate(T goi18n.TranslateFunc)

type AuthError

type AuthError interface {
	SetTranslationParams(map[string]any) AuthError
	GetTranslationParams() map[string]any
	SetStatusCode(int) AuthError
	GetStatusCode() int
	SetDetailedError(string)
	GetDetailedError() string
	SetRequestId(string)
	GetRequestId() string
	GetId() string

	Error() string
	Translate(goi18n.TranslateFunc)
	SystemMessage(goi18n.TranslateFunc) string
	ToJson() string
	String() string
}

func NewAuthError

func NewAuthError(id, details string) AuthError

Error constructors

func NewExpiredTokenError

func NewExpiredTokenError(id, details string) AuthError

Example: AuthError for expired token

func NewInvalidTokenError

func NewInvalidTokenError(id, details string) AuthError

Example: AuthError for invalid token

func NewPermissionForbiddenError

func NewPermissionForbiddenError(id, details string) AuthError

func NewUnauthorizedError

func NewUnauthorizedError(id, details string) AuthError

type AuthorizationError

type AuthorizationError struct {
	Id            string `json:"id"`
	Where         string `json:"where,omitempty"`
	Status        string `json:"status"`
	DetailedError string `json:"detail"`
	RequestId     string `json:"request_id,omitempty"`
	StatusCode    int    `json:"code,omitempty"`
	// contains filtered or unexported fields
}

func (*AuthorizationError) Error

func (err *AuthorizationError) Error() string

func (*AuthorizationError) GetDetailedError

func (err *AuthorizationError) GetDetailedError() string

func (*AuthorizationError) GetId

func (err *AuthorizationError) GetId() string

func (*AuthorizationError) GetRequestId

func (err *AuthorizationError) GetRequestId() string

func (*AuthorizationError) GetStatusCode

func (err *AuthorizationError) GetStatusCode() int

func (*AuthorizationError) GetTranslationParams

func (err *AuthorizationError) GetTranslationParams() map[string]any

func (*AuthorizationError) SetDetailedError

func (err *AuthorizationError) SetDetailedError(details string)

func (*AuthorizationError) SetRequestId

func (err *AuthorizationError) SetRequestId(id string)

func (*AuthorizationError) SetStatusCode

func (err *AuthorizationError) SetStatusCode(code int) AuthError

func (*AuthorizationError) SetTranslationParams

func (err *AuthorizationError) SetTranslationParams(params map[string]any) AuthError

func (*AuthorizationError) String

func (err *AuthorizationError) String() string

func (*AuthorizationError) SystemMessage

func (err *AuthorizationError) SystemMessage(T goi18n.TranslateFunc) string

func (*AuthorizationError) ToJson

func (err *AuthorizationError) ToJson() string

func (*AuthorizationError) Translate

func (err *AuthorizationError) Translate(T goi18n.TranslateFunc)

type DBCheckViolationError

type DBCheckViolationError struct {
	DBError
	Check string
}

DBCheckViolationError indicates a check constraint violation.

func NewDBCheckViolationError

func NewDBCheckViolationError(id, check string) *DBCheckViolationError

type DBConflictError

type DBConflictError struct {
	DBError
}

DBConflictError indicates a conflict in the database operation (e.g., version mismatch).

func NewDBConflictError

func NewDBConflictError(id, message string) *DBConflictError

NewDBConflictError creates a new DBConflictError with the specified ID and message.

type DBEntityConflictError

type DBEntityConflictError struct {
	DBError
}

DBEntityConflictError indicates a conflict in entity requests.

func NewDBEntityConflictError

func NewDBEntityConflictError(id string) *DBEntityConflictError

type DBError

type DBError struct {
	ID      string
	Message string
}

DBError represents a generic database error.

func NewDBError

func NewDBError(id, message string) *DBError

NewDBError creates a new DBError with the specified ID and message.

func (*DBError) Error

func (e *DBError) Error() string

Error implements the error interface for DBError.

type DBForbiddenError

type DBForbiddenError struct {
	DBError
}

DBForbiddenError indicates that the user is forbidden from performing an action.

func NewDBForbiddenError

func NewDBForbiddenError(id, message string) *DBForbiddenError

NewDBForbiddenError creates a new DBForbiddenError with the specified ID and message.

type DBForeignKeyViolationError

type DBForeignKeyViolationError struct {
	DBError
	Column          string
	Value           string
	ForeignKeyTable string
}

DBForeignKeyViolationError indicates a foreign key constraint violation.

func NewDBForeignKeyViolationError

func NewDBForeignKeyViolationError(id, column, value, foreignKey string) *DBForeignKeyViolationError

type DBInternalError

type DBInternalError struct {
	Reason error
	DBError
}

DBInternalError indicates an internal database error.

func NewDBInternalError

func NewDBInternalError(id string, reason error) *DBInternalError

func (*DBInternalError) Error

func (d *DBInternalError) Error() string

Error implements the error interface for DBInternalError.

type DBNoRowsError

type DBNoRowsError struct {
	DBError
}

DBNoRowsError indicates that no rows were found for a query.

func NewDBNoRowsError

func NewDBNoRowsError(id string) *DBNoRowsError

type DBNotFoundError

type DBNotFoundError struct {
	DBError
}

DBNotFoundError indicates that a specific entity was not found.

func NewDBNotFoundError

func NewDBNotFoundError(id, message string) *DBNotFoundError

NewDBNotFoundError creates a new DBNotFoundError with the specified ID and message.

type DBNotNullViolationError

type DBNotNullViolationError struct {
	DBError
	Table  string
	Column string
}

DBNotNullViolationError indicates a not-null constraint violation.

func NewDBNotNullViolationError

func NewDBNotNullViolationError(id, table, column string) *DBNotNullViolationError

type DBUniqueViolationError

type DBUniqueViolationError struct {
	DBError
	Column string
	Value  string
}

DBUniqueViolationError indicates a unique constraint violation.

func NewDBUniqueViolationError

func NewDBUniqueViolationError(id, column, value string) *DBUniqueViolationError

Jump to

Keyboard shortcuts

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