Documentation
¶
Index ¶
- Variables
- func IsDomainError(err error, kind ...ErrorKind) bool
- func NewCompoundError(summary string, errs ...error) error
- func ToHTTPStatus(err error) int
- type CompoundError
- type DomainError
- func Conflict(msg string) *DomainError
- func Conflictf(format string, args ...interface{}) *DomainError
- func Forbidden(msg string) *DomainError
- func Internal(msg string, cause error) *DomainError
- func Internalf(cause error, format string, args ...interface{}) *DomainError
- func NotFound(resource, id string) *DomainError
- func NotFoundMsg(msg string) *DomainError
- func Unauthorized(msg string) *DomainError
- func Unavailable(msg string) *DomainError
- func Validation(msg string) *DomainError
- func Validationf(format string, args ...interface{}) *DomainError
- type ErrorCode
- type ErrorKind
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func IsDomainError ¶
IsDomainError checks if an error is a DomainError and optionally matches a specific kind
func NewCompoundError ¶
func ToHTTPStatus ¶
ToHTTPStatus maps an error to an HTTP status code. This should ONLY be called at the controller/transport layer.
Types ¶
type CompoundError ¶
type CompoundError struct {
Errs []error
// contains filtered or unexported fields
}
func (*CompoundError) Error ¶
func (c *CompoundError) Error() string
type DomainError ¶
DomainError represents a business logic error without HTTP coupling. Services and repositories should return DomainErrors instead of ErrorCode to maintain proper layer separation.
func Conflict ¶
func Conflict(msg string) *DomainError
Conflict creates a conflict error (maps to 409 Conflict)
func Conflictf ¶
func Conflictf(format string, args ...interface{}) *DomainError
Conflictf creates a conflict error with formatted message
func Forbidden ¶
func Forbidden(msg string) *DomainError
Forbidden creates a forbidden error (maps to 403 Forbidden)
func Internal ¶
func Internal(msg string, cause error) *DomainError
Internal creates an internal error (maps to 500 Internal Server Error)
func Internalf ¶
func Internalf(cause error, format string, args ...interface{}) *DomainError
Internalf creates an internal error with formatted message
func NotFound ¶
func NotFound(resource, id string) *DomainError
NotFound creates a not found error (maps to 404 Not Found)
func NotFoundMsg ¶
func NotFoundMsg(msg string) *DomainError
NotFoundMsg creates a not found error with custom message
func Unauthorized ¶
func Unauthorized(msg string) *DomainError
Unauthorized creates an unauthorized error (maps to 401 Unauthorized)
func Unavailable ¶
func Unavailable(msg string) *DomainError
Unavailable creates an unavailable error (maps to 503 Service Unavailable)
func Validation ¶
func Validation(msg string) *DomainError
Validation creates a validation error (maps to 400 Bad Request)
func Validationf ¶
func Validationf(format string, args ...interface{}) *DomainError
Validationf creates a validation error with formatted message
func (*DomainError) Error ¶
func (e *DomainError) Error() string
func (*DomainError) Unwrap ¶
func (e *DomainError) Unwrap() error
type ErrorCode ¶
func NewErrorCode ¶
func ToErrorCode ¶
ToErrorCode converts any error to an ErrorCode for HTTP response serialization. This should ONLY be called at the controller/transport layer.