Documentation
¶
Index ¶
- func As[T error](rawErr error) (T, bool)
- func As0[T error](rawErr error) bool
- func Is(err, target error) bool
- func IsNot(err, target error) bool
- func NoErr(err error)
- func NoErr2[T any](val T, err error) T
- type CodedError
- func AlreadyExistsError(resource string) *CodedError
- func DuplicateNameError(resource, name string) *CodedError
- func ForbiddenError(message string) *CodedError
- func IsCodedError(err error) (*CodedError, bool)
- func NewCodedError(code ErrorCode, message string) *CodedError
- func NewCodedErrorWithExtensions(code ErrorCode, message string, extensions map[string]any) *CodedError
- func NotFoundError(resource string) *CodedError
- func UnauthorizedError(message string) *CodedError
- func ValidationError(message string) *CodedError
- type ErrorCode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CodedError ¶ added in v0.9.28
CodedError is an error with a machine-readable code.
func AlreadyExistsError ¶ added in v0.9.28
func AlreadyExistsError(resource string) *CodedError
AlreadyExistsError creates a generic already exists error.
func DuplicateNameError ¶ added in v0.9.28
func DuplicateNameError(resource, name string) *CodedError
DuplicateNameError creates an error for duplicate name conflicts.
func ForbiddenError ¶ added in v0.9.28
func ForbiddenError(message string) *CodedError
ForbiddenError creates a forbidden error.
func IsCodedError ¶ added in v0.9.28
func IsCodedError(err error) (*CodedError, bool)
IsCodedError checks if an error is a CodedError.
func NewCodedError ¶ added in v0.9.28
func NewCodedError(code ErrorCode, message string) *CodedError
NewCodedError creates a new coded error.
func NewCodedErrorWithExtensions ¶ added in v0.9.28
func NewCodedErrorWithExtensions(code ErrorCode, message string, extensions map[string]any) *CodedError
NewCodedErrorWithExtensions creates a coded error with extensions.
func NotFoundError ¶ added in v0.9.28
func NotFoundError(resource string) *CodedError
NotFoundError creates a not found error.
func UnauthorizedError ¶ added in v0.9.28
func UnauthorizedError(message string) *CodedError
UnauthorizedError creates an unauthenticated error.
func ValidationError ¶ added in v0.9.28
func ValidationError(message string) *CodedError
ValidationError creates a validation error.
func (*CodedError) Error ¶ added in v0.9.28
func (e *CodedError) Error() string
Error implements the error interface.
func (*CodedError) Unwrap ¶ added in v0.9.28
func (e *CodedError) Unwrap() error
Unwrap returns the underlying error.
func (*CodedError) WithCause ¶ added in v0.9.28
func (e *CodedError) WithCause(err error) *CodedError
WithCause adds a cause error.
func (*CodedError) WithExtension ¶ added in v0.9.28
func (e *CodedError) WithExtension(key string, value any) *CodedError
WithExtension adds a single extension.
type ErrorCode ¶ added in v0.9.28
type ErrorCode string
ErrorCode represents application error codes These codes can be mapped to GraphQL extensions.code.
const ( // ErrCodeInvalidInput indicates a generic invalid input. ErrCodeInvalidInput ErrorCode = "INVALID_INPUT" // ErrCodeValidationFailed indicates validation failure. ErrCodeValidationFailed ErrorCode = "VALIDATION_FAILED" // ErrCodeDuplicateName indicates duplicate name conflict. ErrCodeDuplicateName ErrorCode = "DUPLICATE_NAME" // ErrCodeAlreadyExists indicates resource already exists. ErrCodeAlreadyExists ErrorCode = "ALREADY_EXISTS" // ErrCodeNotFound indicates requested resource was not found. ErrCodeNotFound ErrorCode = "NOT_FOUND" // ErrCodeUnauthenticated indicates authentication is required. ErrCodeUnauthenticated ErrorCode = "UNAUTHENTICATED" // ErrCodeForbidden indicates insufficient permissions. ErrCodeForbidden ErrorCode = "FORBIDDEN" // ErrCodeInternalServerError indicates an unexpected server error. ErrCodeInternalServerError ErrorCode = "INTERNAL_SERVER_ERROR" )