pub struct ErrorEvent {
pub when: DateTime<Utc>,
pub scope: ErrorScope,
pub error: WeaveError,
pub tags: Vec<String>,
pub context: Value,
}Expand description
Represents an error event with scope, error details, tags, and context.
§JSON Serialization Format
ErrorEvent serializes to JSON with the following structure:
{
"when": "2025-11-02T10:30:00Z",
"scope": {
"scope": "node",
"kind": "Parser",
"step": 1
},
"error": {
"message": "Failed to parse input",
"cause": {
"message": "Invalid JSON syntax",
"cause": null,
"details": {"line": 3, "column": 15}
},
"details": {"input_length": 1024}
},
"tags": ["validation", "retryable"],
"context": {
"file": "/tmp/input.json",
"user_id": 12345
}
}The scope field uses a tagged union format with a discriminator field named "scope".
Supported scope variants are:
"node": Requireskind(string) andstep(u64)"scheduler": Requiresstep(u64)"runner": Requiressession(string) andstep(u64)"app": No additional fields
See docs/schemas/error_event.json for the complete JSON Schema specification.
§Examples
Using constructors and builders:
use weavegraph::channels::errors::{ErrorEvent, WeaveError};
use serde_json::json;
let event = ErrorEvent::node("Parser", 1, WeaveError::msg("Parse error"))
.with_tag("validation")
.with_context(json!({"line": 42}));
// Serialize to JSON
let json_str = serde_json::to_string(&event).unwrap();Fields§
§when: DateTime<Utc>Timestamp at which the error occurred.
scope: ErrorScopeScope identifying where in the workflow the error originated.
error: WeaveErrorStructured error payload describing the failure.
Arbitrary string tags for filtering and categorization.
context: ValueOptional additional context data as a JSON value.
Implementations§
Source§impl ErrorEvent
impl ErrorEvent
Sourcepub fn node<S: Into<String>>(kind: S, step: u64, error: WeaveError) -> Self
pub fn node<S: Into<String>>(kind: S, step: u64, error: WeaveError) -> Self
Create a node-scoped error event.
§Example
use weavegraph::channels::errors::{ErrorEvent, WeaveError};
let err = ErrorEvent::node("my_node", 1, WeaveError::msg("Something failed"));Sourcepub fn scheduler(step: u64, error: WeaveError) -> Self
pub fn scheduler(step: u64, error: WeaveError) -> Self
Create a scheduler-scoped error event.
§Example
use weavegraph::channels::errors::{ErrorEvent, WeaveError};
let err = ErrorEvent::scheduler(5, WeaveError::msg("Scheduling conflict"));Sourcepub fn runner<S: Into<String>>(session: S, step: u64, error: WeaveError) -> Self
pub fn runner<S: Into<String>>(session: S, step: u64, error: WeaveError) -> Self
Create a runner-scoped error event.
§Example
use weavegraph::channels::errors::{ErrorEvent, WeaveError};
let err = ErrorEvent::runner("session_123", 10, WeaveError::msg("Runtime error"));Sourcepub fn app(error: WeaveError) -> Self
pub fn app(error: WeaveError) -> Self
Create an app-scoped error event.
§Example
use weavegraph::channels::errors::{ErrorEvent, WeaveError};
let err = ErrorEvent::app(WeaveError::msg("Application startup failed"));Add multiple tags to this error event.
§Example
use weavegraph::channels::errors::{ErrorEvent, WeaveError};
let err = ErrorEvent::node("my_node", 1, WeaveError::msg("Invalid input"))
.with_tags(vec!["validation".to_string(), "critical".to_string()]);Sourcepub fn with_tag<S: Into<String>>(self, tag: S) -> Self
pub fn with_tag<S: Into<String>>(self, tag: S) -> Self
Add a single tag to this error event.
§Example
use weavegraph::channels::errors::{ErrorEvent, WeaveError};
let err = ErrorEvent::node("my_node", 1, WeaveError::msg("Invalid input"))
.with_tag("validation");Sourcepub fn with_context(self, context: Value) -> Self
pub fn with_context(self, context: Value) -> Self
Add context metadata to this error event.
§Example
use weavegraph::channels::errors::{ErrorEvent, WeaveError};
use serde_json::json;
let err = ErrorEvent::node("my_node", 1, WeaveError::msg("Invalid input"))
.with_context(json!({"field": "username", "value": ""}));Trait Implementations§
Source§impl Clone for ErrorEvent
impl Clone for ErrorEvent
Source§fn clone(&self) -> ErrorEvent
fn clone(&self) -> ErrorEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ErrorEvent
impl Debug for ErrorEvent
Source§impl Default for ErrorEvent
impl Default for ErrorEvent
Source§fn default() -> ErrorEvent
fn default() -> ErrorEvent
Source§impl<'de> Deserialize<'de> for ErrorEvent
impl<'de> Deserialize<'de> for ErrorEvent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ErrorEvent
impl PartialEq for ErrorEvent
Source§fn eq(&self, other: &ErrorEvent) -> bool
fn eq(&self, other: &ErrorEvent) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for ErrorEvent
impl Serialize for ErrorEvent
impl Eq for ErrorEvent
impl StructuralPartialEq for ErrorEvent
Auto Trait Implementations§
impl Freeze for ErrorEvent
impl RefUnwindSafe for ErrorEvent
impl Send for ErrorEvent
impl Sync for ErrorEvent
impl Unpin for ErrorEvent
impl UnsafeUnpin for ErrorEvent
impl UnwindSafe for ErrorEvent
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> 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 more