Documentation
¶
Overview ¶
Package result provides a discriminated Result type for expected failures in the agent stack.
Index ¶
- func CodeOf(err error) string
- func FileResultOrSessionError[T any](r Result[T, FileError], message string) (T, error)
- func GetOrError[T any, E error](r Result[T, E]) (T, error)
- func IsCode(err error, code string) bool
- func IsContextOverflowErr(err error) bool
- func IsNonOverflowText(text string) bool
- func MatchesOverflowText(text string) bool
- func ToHarnessError(subsystem, message string, cause error) error
- func WrapOverflowError(err error) error
- type BranchSummaryError
- type CodedError
- type CompactionError
- type ExecutionError
- type FileError
- type HarnessError
- type OverflowError
- type ParseError
- type Result
- type SessionError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileResultOrSessionError ¶
FileResultOrSessionError adapts a filesystem Result to a SessionError at storage boundaries.
func GetOrError ¶
GetOrError returns the success value or the failure as a standard Go error. Intended for adapter boundaries such as Harness and Session public APIs.
func IsContextOverflowErr ¶ added in v0.95.0
IsContextOverflowErr reports whether an LLM error indicates context window overflow.
func IsNonOverflowText ¶ added in v0.95.0
IsNonOverflowText reports whether text matches known non-overflow provider errors.
func MatchesOverflowText ¶ added in v0.95.0
MatchesOverflowText reports whether text looks like a context overflow message.
func ToHarnessError ¶
ToHarnessError wraps a subsystem failure as a HarnessError for public harness APIs.
func WrapOverflowError ¶ added in v0.95.0
WrapOverflowError wraps an underlying error as a typed OverflowError when overflow is detected.
Types ¶
type BranchSummaryError ¶
type BranchSummaryError struct {
Message string
Cause error
// contains filtered or unexported fields
}
BranchSummaryError describes expected branch summarization failures.
func NewBranchSummaryError ¶
func NewBranchSummaryError(code, message string, cause error) BranchSummaryError
NewBranchSummaryError builds a BranchSummaryError with the given code and message.
func (BranchSummaryError) Code ¶
func (e BranchSummaryError) Code() string
Code returns the stable error code.
func (BranchSummaryError) Error ¶
func (e BranchSummaryError) Error() string
func (BranchSummaryError) Unwrap ¶
func (e BranchSummaryError) Unwrap() error
type CodedError ¶
CodedError is implemented by typed agent errors with stable code strings.
type CompactionError ¶
type CompactionError struct {
Message string
Cause error
// contains filtered or unexported fields
}
CompactionError describes expected context compaction failures.
func NewCompactionError ¶
func NewCompactionError(code, message string, cause error) CompactionError
NewCompactionError builds a CompactionError with the given code and message.
func (CompactionError) Code ¶
func (e CompactionError) Code() string
Code returns the stable error code.
func (CompactionError) Error ¶
func (e CompactionError) Error() string
func (CompactionError) Unwrap ¶
func (e CompactionError) Unwrap() error
type ExecutionError ¶
ExecutionError describes expected shell/process failures.
func NewExecutionError ¶
func NewExecutionError(code, message string, cause error) ExecutionError
NewExecutionError builds an ExecutionError with the given code and message.
func (ExecutionError) Code ¶
func (e ExecutionError) Code() string
Code returns the stable error code.
func (ExecutionError) Error ¶
func (e ExecutionError) Error() string
func (ExecutionError) Unwrap ¶
func (e ExecutionError) Unwrap() error
type FileError ¶
FileError describes expected filesystem failures.
func NewFileError ¶
NewFileError builds a FileError with the given code and message.
type HarnessError ¶
HarnessError normalizes subsystem failures at the harness public API boundary.
func NewHarnessError ¶
func NewHarnessError(code, message string, cause error) HarnessError
NewHarnessError builds a HarnessError with the given code and message.
func (HarnessError) Error ¶
func (e HarnessError) Error() string
func (HarnessError) Unwrap ¶
func (e HarnessError) Unwrap() error
type OverflowError ¶
OverflowError indicates the model context window was exceeded.
func NewOverflowError ¶
func NewOverflowError(message string, cause error) OverflowError
NewOverflowError builds an OverflowError wrapping an underlying cause.
func (OverflowError) Error ¶
func (e OverflowError) Error() string
func (OverflowError) Unwrap ¶
func (e OverflowError) Unwrap() error
type ParseError ¶
ParseError describes JSONL or message payload parse failures.
func NewParseError ¶
func NewParseError(code, message string, cause error) ParseError
NewParseError builds a ParseError with the given code and message.
func (ParseError) Error ¶
func (e ParseError) Error() string
func (ParseError) Unwrap ¶
func (e ParseError) Unwrap() error
type Result ¶
Result is the outcome of a fallible operation. Expected failures use IsOk() == false instead of panics or untyped errors at low-level boundaries.
func (Result[T, E]) ErrorValue ¶
func (r Result[T, E]) ErrorValue() E
ErrorValue returns the typed failure. Callers must check IsOk first.
func (Result[T, E]) Value ¶
func (r Result[T, E]) Value() T
Value returns the success value. Callers must check IsOk first.
func (Result[T, E]) ValueOrZero ¶
ValueOrZero returns the value, typed error, and success flag for explicit branching.
type SessionError ¶
SessionError describes expected session persistence failures.
func NewSessionError ¶
func NewSessionError(code, message string, cause error) SessionError
NewSessionError builds a SessionError with the given code and message.
func (SessionError) Error ¶
func (e SessionError) Error() string
func (SessionError) Unwrap ¶
func (e SessionError) Unwrap() error