failures

package
v0.2.28 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package failures provides the shared structured error boundary used by Codefly plugins, hosts, Mind/editor integrations, and automation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

func Clone(failure *basev0.Failure) *basev0.Failure

Clone returns an independent copy suitable for forwarding across another response boundary.

func Ensure

func Ensure(existing *basev0.Failure, code basev0.FailureCode, operation, message string) *basev0.Failure

Ensure forwards an existing failure or creates the specified fallback when a producer violated the structured-failure contract.

func Extract

func Extract(err error) (*basev0.Failure, bool)

Extract returns the first Codefly Failure packed into a gRPC status.

func ForOutcome

func ForOutcome(success bool, existing *basev0.Failure, code basev0.FailureCode, operation, message string) *basev0.Failure

ForOutcome returns nil for success and an ensured failure for an unsuccessful result.

func FromError

func FromError(operation string, err error) *basev0.Failure

FromError maps context errors and otherwise retains a safe internal failure.

func FromFailure

func FromFailure(failure *basev0.Failure, presentation string, cause error) error

FromFailure converts an existing generated detail into an ordinary Go error without dropping diagnostics, resource identity, process evidence, or causes. presentation is only the local Error() text; the protobuf remains unchanged for downstream extraction.

func GRPC

func GRPC(failure *basev0.Failure) error

GRPC returns a google.rpc.Status-compatible gRPC error carrying Failure as a typed detail. Callers can use Extract without parsing the status message.

func New

func New(code basev0.FailureCode, operation, message string) *basev0.Failure

New creates a universal Failure with transport and retry semantics derived from its stable Codefly code.

func Wrap

func Wrap(code basev0.FailureCode, operation, message string, cause error) error

Wrap returns an ordinary Go error classified with the universal Codefly taxonomy. The optional cause remains available to errors.Is/errors.As.

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error carries a typed Failure through ordinary Go error chains. Plugin code can classify a native/toolchain/domain error once; response helpers and gRPC boundaries recover the same generated protobuf without parsing strings.

func (*Error) CodeflyFailure

func (e *Error) CodeflyFailure() *basev0.Failure

CodeflyFailure exposes the generated detail to FromError.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Jump to

Keyboard shortcuts

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