cli/pkg/errors/errors.go
Snider dbe617c23e refactor: remove GUI packages for CGO-free CLI
Move all Wails-dependent packages to core-gui repo:
- pkg/core, pkg/display, pkg/docs, pkg/help, pkg/ide
- pkg/runtime, pkg/webview, pkg/workspace, pkg/ws
- pkg/plugin, pkg/config, pkg/i18n, pkg/module
- pkg/crypt, pkg/io, pkg/process

Add pkg/errors with simple E() helper for error wrapping.
Update go.work to only include CLI-relevant packages.
CLI now builds with CGO_ENABLED=0 - no linker warnings.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 12:15:01 +00:00

28 lines
699 B
Go

// Package errors provides standardized error handling for the Core CLI.
package errors
import "fmt"
// Error represents a standardized error with operational context.
type Error struct {
Op string // Operation being performed
Msg string // Human-readable message
Err error // Underlying error
}
// E creates a new Error with operation context.
func E(op, msg string, err error) error {
if err == nil {
return &Error{Op: op, Msg: msg}
}
return &Error{Op: op, Msg: msg, Err: err}
}
func (e *Error) Error() string {
if e.Err != nil {
return fmt.Sprintf("%s: %s: %v", e.Op, e.Msg, e.Err)
}
return fmt.Sprintf("%s: %s", e.Op, e.Msg)
}
func (e *Error) Unwrap() error { return e.Err }