Documentation
¶
Overview ¶
Package errors provides error handling for QNTX.
This package re-exports github.com/cockroachdb/errors, providing:
- Stack traces for debugging
- Error wrapping and context
- PII-safe error formatting
- Network portability for distributed systems
- Sentry integration
Usage:
// Create new error
err := errors.New("something went wrong")
// Wrap with context
if err := doSomething(); err != nil {
return errors.Wrap(err, "failed to do something")
}
// Add hints for users
return errors.WithHint(err, "try increasing the timeout")
// Check errors
if errors.Is(err, sql.ErrNoRows) {
// handle not found
}
For full documentation see: https://pkg.go.dev/github.com/cockroachdb/errors
Index ¶
- Variables
- func IsInvalidRequestError(err error) bool
- func IsNotFoundError(err error) bool
- func IsServiceUnavailableError(err error) bool
- func NewInvalidRequestError(format string, args ...interface{}) error
- func NewNotFoundError(format string, args ...interface{}) error
- func WrapInvalidRequest(err error, context string) error
- func WrapNotFound(err error, context string) error
Constants ¶
This section is empty.
Variables ¶
var ( New = crdb.New Newf = crdb.Newf Wrap = crdb.Wrap Wrapf = crdb.Wrapf WithStack = crdb.WithStack WithMessage = crdb.WithMessage WithMessagef = crdb.WithMessagef )
Core error creation and wrapping
var ( WithHint = crdb.WithHint WithHintf = crdb.WithHintf WithDetail = crdb.WithDetail WithDetailf = crdb.WithDetailf WithSafeDetails = crdb.WithSafeDetails WithSecondaryError = crdb.WithSecondaryError )
User-facing messages and details
var ( Is = crdb.Is IsAny = crdb.IsAny As = crdb.As Unwrap = crdb.Unwrap UnwrapOnce = crdb.UnwrapOnce UnwrapAll = crdb.UnwrapAll GetAllHints = crdb.GetAllHints GetAllDetails = crdb.GetAllDetails FlattenHints = crdb.FlattenHints FlattenDetails = crdb.FlattenDetails )
Error inspection
var ( Handled = crdb.Handled HandledWithMessage = crdb.HandledWithMessage WithDomain = crdb.WithDomain GetDomain = crdb.GetDomain WithContextTags = crdb.WithContextTags EncodeError = crdb.EncodeError DecodeError = crdb.DecodeError GetReportableStackTrace = crdb.GetReportableStackTrace )
Advanced features
var ( AssertionFailedf = crdb.AssertionFailedf NewAssertionErrorWithWrappedErrf = crdb.NewAssertionErrorWithWrappedErrf )
Assertions and panics
var ( // ErrNotFound indicates the requested resource does not exist ErrNotFound = New("not found") // ErrInvalidRequest indicates the request was malformed or invalid ErrInvalidRequest = New("invalid request") ErrUnauthorized = New("unauthorized") // ErrForbidden indicates the request is not allowed for this user ErrForbidden = New("forbidden") ErrServiceUnavailable = New("service unavailable") // ErrTimeout indicates an operation timed out ErrTimeout = New("operation timed out") // ErrConflict indicates a resource conflict (e.g., duplicate key) ErrConflict = New("resource conflict") )
Common sentinel errors for use across QNTX. Use these with errors.Is() for type-safe error checking. Wrap these with errors.Wrap() to add context while preserving the type.
var GetStack = crdb.GetReportableStackTrace
GetStack is an alias for GetReportableStackTrace for convenience.
Functions ¶
func IsInvalidRequestError ¶ added in v0.20.1
IsInvalidRequestError checks if an error is or wraps ErrInvalidRequest
func IsNotFoundError ¶ added in v0.20.1
IsNotFoundError checks if an error is or wraps ErrNotFound. Also provides backward compatibility with string-based "not found" errors.
func IsServiceUnavailableError ¶ added in v0.20.1
IsServiceUnavailableError checks if an error is or wraps ErrServiceUnavailable
func NewInvalidRequestError ¶ added in v0.20.1
NewInvalidRequestError creates an invalid-request error with a formatted message
func NewNotFoundError ¶ added in v0.20.1
NewNotFoundError creates a not-found error with a formatted message
func WrapInvalidRequest ¶ added in v0.20.1
WrapInvalidRequest wraps an error as an invalid-request error with context
func WrapNotFound ¶ added in v0.20.1
WrapNotFound wraps an error as a not-found error with context
Types ¶
This section is empty.