apperror

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 1 Imported by: ? 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

Overview

Package apperror defines the platform-wide application error type used to map domain and application failures to transport-level responses.

Index

Constants

View Source
const (
	CodeValidation     = Code(TypeValidation)
	CodeNotFound       = Code(TypeNotFound)
	CodeAuthentication = Code(TypeAuthentication)
	CodeAuthorization  = Code(TypeAuthorization)
)

Variables

This section is empty.

Functions

func IsAppError

func IsAppError(err error) bool

Types

type AppError

type AppError struct {
	Type    Type          `json:"type"`
	Code    Code          `json:"code"`
	Message string        `json:"message"`
	Details []interface{} `json:"details"`
}

func Authentication

func Authentication(message string) *AppError

func Authorization

func Authorization(message string) *AppError

func Logic

func Logic(message string, code Code) *AppError

func NotFound

func NotFound(message string) *AppError

func NotFoundEntity

func NotFoundEntity(entity string) *AppError

func Validation

func Validation(validationErrors map[string]string) *AppError

func (*AppError) Error

func (e *AppError) Error() string

func (*AppError) IsAuthentication

func (e *AppError) IsAuthentication() bool

func (*AppError) IsAuthorization

func (e *AppError) IsAuthorization() bool

func (*AppError) IsLogic

func (e *AppError) IsLogic() bool

func (*AppError) IsNotFound

func (e *AppError) IsNotFound() bool

func (*AppError) IsValidation

func (e *AppError) IsValidation() bool

type Code

type Code string

type Type

type Type string
const (
	TypeLogic          Type = "logic"
	TypeValidation     Type = "validation"
	TypeNotFound       Type = "not_found"
	TypeAuthentication Type = "authentication"
	TypeAuthorization  Type = "authorization"
)

Jump to

Keyboard shortcuts

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