result

package
v0.95.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package result provides a discriminated Result type for expected failures in the agent stack.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CodeOf

func CodeOf(err error) string

CodeOf returns the stable code for a typed agent error, or empty string.

func FileResultOrSessionError

func FileResultOrSessionError[T any](r Result[T, FileError], message string) (T, error)

FileResultOrSessionError adapts a filesystem Result to a SessionError at storage boundaries.

func GetOrError

func GetOrError[T any, E error](r Result[T, E]) (T, error)

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 IsCode

func IsCode(err error, code string) bool

IsCode reports whether err is a CodedError with the given code.

func IsContextOverflowErr added in v0.95.0

func IsContextOverflowErr(err error) bool

IsContextOverflowErr reports whether an LLM error indicates context window overflow.

func IsNonOverflowText added in v0.95.0

func IsNonOverflowText(text string) bool

IsNonOverflowText reports whether text matches known non-overflow provider errors.

func MatchesOverflowText added in v0.95.0

func MatchesOverflowText(text string) bool

MatchesOverflowText reports whether text looks like a context overflow message.

func ToHarnessError

func ToHarnessError(subsystem, message string, cause error) error

ToHarnessError wraps a subsystem failure as a HarnessError for public harness APIs.

func WrapOverflowError added in v0.95.0

func WrapOverflowError(err error) error

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

type CodedError interface {
	error
	Code() string
}

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

type ExecutionError struct {
	Message string
	Cause   error
	// contains filtered or unexported fields
}

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

type FileError struct {
	Message string
	Cause   error
	// contains filtered or unexported fields
}

FileError describes expected filesystem failures.

func NewFileError

func NewFileError(code, message string, cause error) FileError

NewFileError builds a FileError with the given code and message.

func (FileError) Code

func (e FileError) Code() string

Code returns the stable error code.

func (FileError) Error

func (e FileError) Error() string

func (FileError) Unwrap

func (e FileError) Unwrap() error

type HarnessError

type HarnessError struct {
	Message string
	Cause   error
	// contains filtered or unexported fields
}

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) Code

func (e HarnessError) Code() string

Code returns the stable error code.

func (HarnessError) Error

func (e HarnessError) Error() string

func (HarnessError) Unwrap

func (e HarnessError) Unwrap() error

type OverflowError

type OverflowError struct {
	Message string
	Cause   error
}

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) Code

func (OverflowError) Code() string

Code returns the stable error code.

func (OverflowError) Error

func (e OverflowError) Error() string

func (OverflowError) Unwrap

func (e OverflowError) Unwrap() error

type ParseError

type ParseError struct {
	Message string
	Cause   error
	// contains filtered or unexported fields
}

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) Code

func (e ParseError) Code() string

Code returns the stable error code.

func (ParseError) Error

func (e ParseError) Error() string

func (ParseError) Unwrap

func (e ParseError) Unwrap() error

type Result

type Result[T any, E error] struct {
	// contains filtered or unexported fields
}

Result is the outcome of a fallible operation. Expected failures use IsOk() == false instead of panics or untyped errors at low-level boundaries.

func Err

func Err[T any, E error](err E) Result[T, E]

Err constructs a failed Result.

func Ok

func Ok[T any, E error](value T) Result[T, E]

Ok constructs a successful Result.

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]) IsOk

func (r Result[T, E]) IsOk() bool

IsOk reports whether the operation succeeded.

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

func (r Result[T, E]) ValueOrZero() (T, E, bool)

ValueOrZero returns the value, typed error, and success flag for explicit branching.

type SessionError

type SessionError struct {
	Message string
	Cause   error
	// contains filtered or unexported fields
}

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) Code

func (e SessionError) Code() string

Code returns the stable error code.

func (SessionError) Error

func (e SessionError) Error() string

func (SessionError) Unwrap

func (e SessionError) Unwrap() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL