errors

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRequest = NewAPIError(http.StatusBadRequest, "Invalid request")
	ErrUnauthorized   = NewAPIError(http.StatusUnauthorized, "Unauthorized")
	ErrForbidden      = NewAPIError(http.StatusForbidden, "Forbidden")
	ErrNotFound       = NewAPIError(http.StatusNotFound, "Resource not found")
	ErrInternal       = NewAPIError(http.StatusInternalServerError, "Internal server error")
)

Common API errors

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Details string `json:"details,omitempty"`
}

APIError represents an error response from the API

func NewAPIError

func NewAPIError(code int, message string, details ...string) *APIError

NewAPIError creates a new APIError

func (*APIError) Error

func (e *APIError) Error() string

Error implements the error interface

type ValidationError

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

ValidationError represents a validation error

type ValidationErrors

type ValidationErrors struct {
	Errors []ValidationError `json:"errors"`
}

ValidationErrors represents multiple validation errors

func (*ValidationErrors) Error

func (e *ValidationErrors) Error() string

Error implements the error interface

Jump to

Keyboard shortcuts

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