Documentation
¶
Overview ¶
Package errors provides structured error handling for Core applications.
Errors include operational context (what was being done) and support error wrapping for debugging while keeping user-facing messages clean:
err := errors.E("user.Create", "email already exists", nil)
err := errors.Wrap(dbErr, "user.Create", "failed to save user")
// Check error types
if errors.Is(err, sql.ErrNoRows) { ... }
// Extract operation
var e *errors.Error
if errors.As(err, &e) {
fmt.Println("Operation:", e.Op)
}
Index ¶
- func As(err error, target any) bool
- func Code(code, msg string) error
- func E(op, msg string, err error) error
- func ErrCode(err error) string
- func Is(err, target error) bool
- func Join(errs ...error) error
- func Message(err error) string
- func New(text string) error
- func Op(err error) string
- func Root(err error) error
- func Wrap(err error, op, msg string) error
- func WrapCode(err error, code, op, msg string) error
- type Error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Code ¶
Code creates an error with just a code and message.
return errors.Code("ERR_VALIDATION", "invalid email format")
func E ¶
E creates a new Error with operation context.
err := errors.E("config.Load", "file not found", os.ErrNotExist)
err := errors.E("api.Call", "rate limited", nil)
func Message ¶
Message extracts the message from an error. For Error types, returns Msg; otherwise returns err.Error().
Types ¶
Click to show internal directories.
Click to hide internal directories.