apperror

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	CodeCommonInvalidJSON       = "common.invalid_json"
	CodeCommonInvalidParam      = "common.invalid_param"
	CodeCommonValidationFailed  = "common.validation_failed"
	CodeCommonBadRequest        = "common.bad_request"
	CodeCommonNotFound          = "common.not_found"
	CodeCommonDuplicateResource = "common.duplicate_resource"
	CodeCommonDatabaseError     = "common.database_error"
	CodeCommonInternalError     = "common.internal_error"

	CodeAuthUnauthorized       = "auth.unauthorized"
	CodeAuthForbidden          = "auth.forbidden"
	CodeAuthInvalidToken       = "auth.invalid_token"
	CodeAuthExpiredToken       = "auth.expired_token"
	CodeAuthInvalidCredentials = "auth.invalid_credentials"
	CodeAuthAPIKeyExpired      = "auth.api_key_expired"
	CodeAuthAPIKeyMissing      = "auth.api_key_missing"
	CodeAuthPasswordIncorrect  = "auth.password_incorrect"
	CodeAuthAPIKeyDisabled     = "auth.api_key_disabled"
	CodeAuthAPIKeyCostExceeded = "auth.api_key_cost_exceeded"

	CodeSiteSub2APIAPIKeyRequired      = "site.sub2api.api_key_required"
	CodeSiteSub2APIModelAPIKeyRequired = "site.sub2api.model_api_key_required"
	CodeSiteSub2APIEnvelopeFailed      = "site.sub2api.envelope_failed"
	CodeSiteSub2APIMissingData         = "site.sub2api.missing_data"

	CodeSiteSyncMissingGroupKey = "site.sync.missing_group_key"
	CodeSiteAuthLoginFailed     = "site.auth.login_failed"
	CodeSiteAuthTokenMissing    = "site.auth.token_missing"
	CodeSiteUpstreamHTTPError   = "site.upstream.http_error"
	CodeSiteUpstreamDecodeError = "site.upstream.decode_error"
	CodeSiteAccessTokenRequired = "site.auth.access_token_required"
	CodeSiteDirectTokenRequired = "site.auth.direct_token_required"
	CodeSiteImportEmptyPayload  = "site.import.empty_payload"
	CodeSiteImportInvalidFormat = "site.import.invalid_format"
	CodeSiteUnsupportedPlatform = "site.unsupported_platform"
)

Variables

This section is empty.

Functions

func Code

func Code(err error) string

func IsCode

func IsCode(err error, code string) bool

func Message

func Message(err error) string

func Params

func Params(err error) map[string]any

func Status

func Status(err error) int

Types

type Error

type Error struct {
	Code    string
	Message string
	Status  int
	Params  map[string]any
	Err     error
}

Error carries a stable machine-readable code plus a default human-readable message.

func InvalidJSON

func InvalidJSON(message string) *Error

func InvalidParam

func InvalidParam(message string) *Error

func New

func New(code string, message string) *Error

func Newf

func Newf(code string, format string, args ...any) *Error

func Wrap

func Wrap(code string, message string, err error) *Error

func Wrapf

func Wrapf(code string, err error, format string, args ...any) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

func (*Error) WithParam

func (e *Error) WithParam(key string, value any) *Error

func (*Error) WithParams

func (e *Error) WithParams(params map[string]any) *Error

func (*Error) WithStatus

func (e *Error) WithStatus(status int) *Error

Jump to

Keyboard shortcuts

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