errors
go
import "github.com/prescriptoo/prescriptoo-api/pkg/errors"Package errors provides standard domain error types across microservices.
Index
func HTTPStatusCode
go
func HTTPStatusCode(code Code) intHTTPStatusCode maps domain error code to HTTP status code.
type AppError
AppError is a structured error containing code, message, and underlying error.
go
type AppError struct {
Code Code `json:"code"`
Message string `json:"message"`
Err error `json:"-"`
}func New
go
func New(code Code, message string, err error) *AppErrorNew creates a new AppError.
func (*AppError) Error
go
func (e *AppError) Error() stringfunc (*AppError) Unwrap
go
func (e *AppError) Unwrap() errortype Code
Code represents a domain error code.
go
type Code stringError codes for common domain errors.
go
const (
CodeNotFound Code = "NOT_FOUND"
CodeAlreadyExists Code = "ALREADY_EXISTS"
CodeInvalidInput Code = "INVALID_INPUT"
CodeUnauthorized Code = "UNAUTHORIZED"
CodeForbidden Code = "FORBIDDEN"
CodeInternalError Code = "INTERNAL_ERROR"
)Generated by gomarkdoc