pub struct KitError { /* private fields */ }Expand description
An opaque, safely formatted failure with bounded normalized evidence.
Messages supplied by callers must already be redacted. Never include native identities, routes, credentials, storage keys, payloads or foreign prose.
use agents_kit::{KitError, error::{ErrorKind, Operation, ErrorPhase, ErrorDetail}};
let error = KitError::integration("model authentication was rejected")
.with_context(Operation::Prompt, ErrorPhase::ModelGeneration)
.with_detail(ErrorDetail::AuthenticationRejected)
.with_http_status(401);
assert_eq!(error.kind(), ErrorKind::Integration);
assert_eq!(error.http_status(), Some(401));Runtime failures cannot be reconstructed from untrusted serialized messages.
let error = agents_kit::KitError::integration("safe failure");
let _ = serde_json::to_string(&error);Implementations§
Source§impl KitError
impl KitError
Sourcepub fn new(kind: ErrorKind, safe_message: impl Into<String>) -> Self
pub fn new(kind: ErrorKind, safe_message: impl Into<String>) -> Self
Constructs a classified failure with already-redacted caller context.
use agents_kit::KitError;
use agents_kit::error::{ErrorKind};
let error = KitError::new(ErrorKind::Integration, "safe dependency failure");
assert_eq!(error.kind(), ErrorKind::Integration);Sourcepub fn invalid_config(message: impl Into<String>) -> Self
pub fn invalid_config(message: impl Into<String>) -> Self
Creates an invalid-configuration failure with safe context.
use agents_kit::KitError;
use agents_kit::error::{ErrorKind};
let error = KitError::invalid_config("safe failure context");
assert_eq!(error.kind(), ErrorKind::InvalidConfig);Sourcepub fn invalid_input(message: impl Into<String>) -> Self
pub fn invalid_input(message: impl Into<String>) -> Self
Creates an invalid-input failure with safe context.
use agents_kit::KitError;
use agents_kit::error::{ErrorKind};
let error = KitError::invalid_input("safe failure context");
assert_eq!(error.kind(), ErrorKind::InvalidInput);Sourcepub fn not_found(message: impl Into<String>) -> Self
pub fn not_found(message: impl Into<String>) -> Self
Creates a proven missing-portable-resource failure.
use agents_kit::KitError;
use agents_kit::error::{ErrorKind};
let error = KitError::not_found("safe failure context");
assert_eq!(error.kind(), ErrorKind::NotFound);Sourcepub fn conflict(message: impl Into<String>) -> Self
pub fn conflict(message: impl Into<String>) -> Self
Creates a durable-fact conflict.
use agents_kit::KitError;
use agents_kit::error::{ErrorKind};
let error = KitError::conflict("safe failure context");
assert_eq!(error.kind(), ErrorKind::Conflict);Sourcepub fn closed(message: impl Into<String>) -> Self
pub fn closed(message: impl Into<String>) -> Self
Creates an owning-lifecycle closure failure.
use agents_kit::KitError;
use agents_kit::error::{ErrorKind};
let error = KitError::closed("safe failure context");
assert_eq!(error.kind(), ErrorKind::Closed);Sourcepub fn busy(message: impl Into<String>) -> Self
pub fn busy(message: impl Into<String>) -> Self
Creates a busy-admission failure.
use agents_kit::KitError;
use agents_kit::error::{ErrorKind};
let error = KitError::busy("safe failure context");
assert_eq!(error.kind(), ErrorKind::Busy);Sourcepub fn cancelled(message: impl Into<String>) -> Self
pub fn cancelled(message: impl Into<String>) -> Self
Creates a durable Agent cancellation failure.
use agents_kit::KitError;
use agents_kit::error::{ErrorKind};
let error = KitError::cancelled("safe failure context");
assert_eq!(error.kind(), ErrorKind::Cancelled);Sourcepub fn timeout(message: impl Into<String>) -> Self
pub fn timeout(message: impl Into<String>) -> Self
Creates a local deadline failure; attach the known owner and duration.
use agents_kit::KitError;
use agents_kit::error::{ErrorKind};
let error = KitError::timeout("safe failure context");
assert_eq!(error.kind(), ErrorKind::Timeout);Sourcepub fn unsupported(message: impl Into<String>) -> Self
pub fn unsupported(message: impl Into<String>) -> Self
Creates an unsupported-semantics failure.
use agents_kit::KitError;
use agents_kit::error::{ErrorKind};
let error = KitError::unsupported("safe failure context");
assert_eq!(error.kind(), ErrorKind::Unsupported);Sourcepub fn not_yet_implemented(message: impl Into<String>) -> Self
pub fn not_yet_implemented(message: impl Into<String>) -> Self
Creates an incomplete-adapter failure.
use agents_kit::KitError;
use agents_kit::error::{ErrorKind};
let error = KitError::not_yet_implemented("safe failure context");
assert_eq!(error.kind(), ErrorKind::NotYetImplemented);Sourcepub fn protocol(message: impl Into<String>) -> Self
pub fn protocol(message: impl Into<String>) -> Self
Creates a malformed or contradictory protocol failure.
use agents_kit::KitError;
use agents_kit::error::{ErrorKind};
let error = KitError::protocol("safe failure context");
assert_eq!(error.kind(), ErrorKind::Protocol);Sourcepub fn invalid_state(message: impl Into<String>) -> Self
pub fn invalid_state(message: impl Into<String>) -> Self
Creates an invalid-owned-state failure.
use agents_kit::KitError;
use agents_kit::error::{ErrorKind};
let error = KitError::invalid_state("safe failure context");
assert_eq!(error.kind(), ErrorKind::InvalidState);Sourcepub fn integration(message: impl Into<String>) -> Self
pub fn integration(message: impl Into<String>) -> Self
Creates a dependency execution failure.
use agents_kit::KitError;
use agents_kit::error::{ErrorKind};
let error = KitError::integration("safe failure context");
assert_eq!(error.kind(), ErrorKind::Integration);Sourcepub fn with_context(self, operation: Operation, phase: ErrorPhase) -> Self
pub fn with_context(self, operation: Operation, phase: ErrorPhase) -> Self
Attaches the caller operation and detecting phase without changing evidence.
use agents_kit::KitError;
use agents_kit::error::{Operation, ErrorPhase};
let error = KitError::protocol("missing reply").with_context(Operation::Prompt, ErrorPhase::ResponseDecode);
assert_eq!(error.context().phase, ErrorPhase::ResponseDecode);Sourcepub fn with_detail(self, detail: ErrorDetail) -> Self
pub fn with_detail(self, detail: ErrorDetail) -> Self
Attaches sourced portable evidence without changing the broad category.
use agents_kit::KitError;
use agents_kit::error::{ErrorDetail};
let error = KitError::protocol("missing reply").with_detail(ErrorDetail::MissingData);
assert_eq!(error.detail(), Some(&ErrorDetail::MissingData));Sourcepub fn with_http_status(self, status: u16) -> Self
pub fn with_http_status(self, status: u16) -> Self
Attaches an observed HTTP status, never an inferred status.
use agents_kit::KitError;
let error = KitError::integration("rejected request").with_http_status(403);
assert_eq!(error.http_status(), Some(403));Sourcepub fn with_cause(self, cause: Self) -> Self
pub fn with_cause(self, cause: Self) -> Self
Attaches a normalized causal failure, separately from cleanup failures.
use agents_kit::KitError;
use agents_kit::error::{ErrorKind};
let error = KitError::integration("generation failed").with_cause(KitError::timeout("dependency deadline elapsed"));
assert_eq!(error.cause().unwrap().kind(), ErrorKind::Timeout);Sourcepub fn with_supplementary(self, error: Self) -> Self
pub fn with_supplementary(self, error: Self) -> Self
Appends independent cleanup or earlier-attempt evidence in observation order.
use agents_kit::KitError;
let error = KitError::protocol("invalid reply").with_supplementary(KitError::integration("cleanup failed"));
assert_eq!(error.supplementary().len(), 1);Sourcepub fn kind(&self) -> ErrorKind
pub fn kind(&self) -> ErrorKind
Returns the broad portable category.
use agents_kit::KitError;
use agents_kit::error::{ErrorKind};
assert_eq!(KitError::closed("agent shut down").kind(), ErrorKind::Closed);Sourcepub fn context(&self) -> &ErrorContext
pub fn context(&self) -> &ErrorContext
Returns the caller operation and detecting phase.
use agents_kit::KitError;
use agents_kit::error::{Operation, ErrorPhase};
let error = KitError::protocol("invalid reply").with_context(Operation::Prompt, ErrorPhase::ResponseDecode);
assert_eq!(error.context().operation, Operation::Prompt);Sourcepub fn detail(&self) -> Option<&ErrorDetail>
pub fn detail(&self) -> Option<&ErrorDetail>
Returns narrower evidence when a detector established it.
use agents_kit::KitError;
use agents_kit::error::{ErrorDetail};
let error = KitError::integration("output truncated").with_detail(ErrorDetail::OutputLimit);
assert_eq!(error.detail(), Some(&ErrorDetail::OutputLimit));Sourcepub fn http_status(&self) -> Option<u16>
pub fn http_status(&self) -> Option<u16>
Returns the actual observed HTTP status.
use agents_kit::KitError;
assert_eq!(KitError::integration("no HTTP response").http_status(), None);Sourcepub fn cause(&self) -> Option<&Self>
pub fn cause(&self) -> Option<&Self>
Returns the normalized causal failure.
use agents_kit::KitError;
assert!(KitError::invalid_input("empty prompt").cause().is_none());Sourcepub fn supplementary(&self) -> &[Self]
pub fn supplementary(&self) -> &[Self]
Returns independent supplementary failures in observation order.
use agents_kit::KitError;
assert!(KitError::invalid_input("empty prompt").supplementary().is_empty());Sourcepub fn diagnostics_truncated(&self) -> bool
pub fn diagnostics_truncated(&self) -> bool
Reports whether any retained diagnostic tree evidence was truncated.
use agents_kit::KitError;
let error = KitError::integration("x".repeat(5000));
assert!(error.diagnostics_truncated());
assert_eq!(error.message().len(), 4096);Trait Implementations§
Source§impl Error for KitError
impl Error for KitError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for KitError
impl RefUnwindSafe for KitError
impl Send for KitError
impl Sync for KitError
impl Unpin for KitError
impl UnsafeUnpin for KitError
impl UnwindSafe for KitError
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> AsErrorSource for Twhere
T: Error + 'static,
impl<T> AsErrorSource for Twhere
T: Error + 'static,
Source§fn as_error_source(&self) -> &(dyn Error + 'static)
fn as_error_source(&self) -> &(dyn Error + 'static)
Source§impl<T> AsErrorSource for Twhere
T: Error + 'static,
impl<T> AsErrorSource for Twhere
T: Error + 'static,
Source§fn as_error_source(&self) -> &(dyn Error + 'static)
fn as_error_source(&self) -> &(dyn Error + 'static)
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.