Skip to main content

ErrorPanel

Struct ErrorPanel 

Source
pub struct ErrorPanel {
    pub code: String,
    pub title: String,
    pub message: Option<String>,
    pub severity: ErrorSeverity,
    pub context: Vec<ErrorContext>,
    pub suggestions: Vec<String>,
    pub caused_by: Vec<CausedBy>,
    pub stack_trace: Option<String>,
    pub timestamp: DateTime<Utc>,
    pub truncated: bool,
}
Expand description

ErrorPanel - The base error display component for RCH.

Provides consistent, actionable error messages with:

  • Error code and title
  • Main message
  • Context key-value pairs
  • Remediation suggestions
  • Error chaining support
  • Timestamp for debugging

Fields§

§code: String

Error code in RCH-Exxx format.

§title: String

Short error title (e.g., “Worker Connection Failed”).

§message: Option<String>

Main error message with details.

§severity: ErrorSeverity

Error severity level.

§context: Vec<ErrorContext>

Context key-value pairs (e.g., Host, Timeout).

§suggestions: Vec<String>

Remediation suggestions (numbered list).

§caused_by: Vec<CausedBy>

Error chain (caused by).

§stack_trace: Option<String>

Stack trace (usually collapsed/hidden).

§timestamp: DateTime<Utc>

Timestamp when the error occurred.

§truncated: bool

Whether the message was truncated (show –verbose hint).

Implementations§

Source§

impl ErrorPanel

Source

pub fn new(code: impl Into<String>, title: impl Into<String>) -> Self

Create a new ErrorPanel with code and title.

§Arguments
  • code - Error code (e.g., “RCH-E042”)
  • title - Short error title (e.g., “Worker Connection Failed”)
Source

pub fn error(code: impl Into<String>, title: impl Into<String>) -> Self

Create an error-level ErrorPanel (red, cross icon).

Source

pub fn warning(code: impl Into<String>, title: impl Into<String>) -> Self

Create a warning-level ErrorPanel (amber, warning icon).

Source

pub fn info(code: impl Into<String>, title: impl Into<String>) -> Self

Create an info-level ErrorPanel (blue, info icon).

Source

pub fn with_severity(self, severity: ErrorSeverity) -> Self

Set the severity level.

Source

pub fn message(self, message: impl Into<String>) -> Self

Set the main error message.

Source

pub fn message_truncated( self, message: impl Into<String>, max_len: usize, ) -> Self

Set the main error message, truncating if too long.

If the message exceeds max_len characters, it will be truncated and truncated will be set to true (shows –verbose hint).

Source

pub fn context(self, key: impl Into<String>, value: impl Into<String>) -> Self

Add a context key-value pair.

Source

pub fn suggestion(self, suggestion: impl Into<String>) -> Self

Add a remediation suggestion.

Source

pub fn suggestions<I, S>(self, suggestions: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Add multiple suggestions at once.

Source

pub fn caused_by(self, message: impl Into<String>, code: Option<String>) -> Self

Add a caused-by error (for error chaining).

Source

pub fn stack_trace(self, trace: impl Into<String>) -> Self

Add a stack trace (shown in verbose mode or dim).

Source

pub fn with_timestamp(self, timestamp: DateTime<Utc>) -> Self

Set the timestamp explicitly.

Source

pub fn render(&self, ctx: OutputContext)

Render the error panel to stderr.

Automatically selects rich or plain output based on context.

Source

pub fn to_json(&self) -> Result<String>

Serialize to JSON string.

Use this for –json mode output.

Source

pub fn to_json_compact(&self) -> Result<String>

Serialize to compact JSON string.

Trait Implementations§

Source§

impl Clone for ErrorPanel

Source§

fn clone(&self) -> ErrorPanel

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ErrorPanel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ErrorPanel

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for ErrorPanel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for ErrorPanel

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl Serialize for ErrorPanel

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<E> IntoErrorPanel for E
where E: Error,

Source§

fn into_panel(self) -> ErrorPanel

Convert this error into an ErrorPanel.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,