errors

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

func Custom

func Custom() *Builder

func Forbidden

func Forbidden() *Builder

func GenerateByStatusCode

func GenerateByStatusCode(code int) *Builder

func InternalServerError

func InternalServerError() *Builder

func InvalidRequest

func InvalidRequest() *Builder

func NotAllowed

func NotAllowed() *Builder

func NotFound

func NotFound() *Builder

func ServiceUnavailable

func ServiceUnavailable() *Builder

func Unauthorized

func Unauthorized() *Builder

func (*Builder) Build

func (b *Builder) Build() *ErrorResponse

func (*Builder) WithErrorCode

func (b *Builder) WithErrorCode(errorCode string) *Builder

func (*Builder) WithMessage

func (b *Builder) WithMessage(message string) *Builder

func (*Builder) WithStatusCode

func (b *Builder) WithStatusCode(code int) *Builder

func (*Builder) WithValidation

func (b *Builder) WithValidation(validation []ValidationError) *Builder

type ErrorMessage

type ErrorMessage struct {
	ErrorCode    string `json:"error_code"`
	ErrorMessage string `json:"error_message"`
}

type ErrorResponse

type ErrorResponse struct {
	HTTPStatusCode int               `json:"status"`
	ErrorMessage   ErrorMessage      `json:"error"`
	Validation     []ValidationError `json:"validation,omitempty"`
}

type ErrorType

type ErrorType string
const (
	ErrInvalidRequest      ErrorType = "INVALID_REQUEST"
	ErrUnauthorized        ErrorType = "UNAUTHORIZED"
	ErrForbidden           ErrorType = "FORBIDDEN"
	ErrNotFound            ErrorType = "NOT_FOUND"
	ErrNotAllowed          ErrorType = "NOT_ALLOWED"
	ErrInternalServerError ErrorType = "INTERNAL_SERVER_ERROR"
	ErrServiceUnavailable  ErrorType = "SERVICE_UNAVAILABLE"
)

type ValidationError

type ValidationError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

Jump to

Keyboard shortcuts

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