Skip to main content

ConfigErrorDisplay

Struct ConfigErrorDisplay 

Source
pub struct ConfigErrorDisplay {
Show 16 fields pub error_code: ErrorCode, pub location: Option<ConfigLocation>, pub snippet: Option<ConfigSnippet>, pub type_mismatch: Option<TypeMismatch>, pub search_paths: Option<ConfigSearchPaths>, pub env_var_name: Option<String>, pub env_var_value: Option<String>, pub profile_name: Option<String>, pub worker_id: Option<String>, pub ssh_key_path: Option<PathBuf>, pub socket_path: Option<PathBuf>, pub permission_mode: Option<String>, pub required_mode: Option<String>, pub raw_error: Option<String>, pub caused_by: Vec<String>, pub custom_message: Option<String>,
}
Expand description

ConfigErrorDisplay - Rich error display for configuration errors.

Builds on ErrorPanel with config-specific context:

  • File location (path, line, column)
  • Content snippets with highlighting
  • Expected vs actual values
  • Config search paths
  • Environment variable issues

Fields§

§error_code: ErrorCode

The underlying error code.

§location: Option<ConfigLocation>

Location in the config file.

§snippet: Option<ConfigSnippet>

Code snippet showing the error.

§type_mismatch: Option<TypeMismatch>

Type mismatch details.

§search_paths: Option<ConfigSearchPaths>

Search paths for “not found” errors.

§env_var_name: Option<String>

Environment variable name (for env errors).

§env_var_value: Option<String>

Environment variable value (for env errors).

§profile_name: Option<String>

Profile name (for profile not found).

§worker_id: Option<String>

Worker ID (for worker config errors).

§ssh_key_path: Option<PathBuf>

SSH key path (for key errors).

§socket_path: Option<PathBuf>

Socket path (for socket errors).

§permission_mode: Option<String>

Permission mode (for permission errors).

§required_mode: Option<String>

Required permission mode.

§raw_error: Option<String>

Raw error message from TOML parser or IO.

§caused_by: Vec<String>

Error chain (caused by).

§custom_message: Option<String>

Custom message override.

Implementations§

Source§

impl ConfigErrorDisplay

Source

pub fn not_found(searched_path: impl Into<PathBuf>) -> Self

Create display for config file not found (E001).

Source

pub fn read_error(file_path: impl Into<PathBuf>) -> Self

Create display for config read error (E002).

Source

pub fn parse_error(file_path: impl Into<PathBuf>) -> Self

Create display for TOML parse error (E003).

Source

pub fn validation_error(file_path: impl Into<PathBuf>) -> Self

Create display for validation error (E004).

Source

pub fn env_error(var_name: impl Into<String>) -> Self

Create display for environment variable error (E005).

Source

pub fn profile_not_found(profile_name: impl Into<String>) -> Self

Create display for profile not found error (E006).

Source

pub fn no_workers(config_path: impl Into<PathBuf>) -> Self

Create display for no workers configured error (E007).

Source

pub fn invalid_worker(worker_id: impl Into<String>) -> Self

Create display for invalid worker error (E008).

Source

pub fn ssh_key_error(key_path: impl Into<PathBuf>) -> Self

Create display for SSH key error (E009).

Source

pub fn socket_path_error(socket_path: impl Into<PathBuf>) -> Self

Create display for socket path error (E010).

Source

pub fn line(self, line: usize) -> Self

Set the line number.

Source

pub fn column(self, column: usize) -> Self

Set the column number.

Source

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

Set the key path within the config.

Source

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

Set a single-line snippet.

Source

pub fn snippet_from_content(self, content: &str, context_lines: usize) -> Self

Set a multi-line snippet from file content.

Source

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

Set the expected type/value.

Source

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

Set the actual type/value found.

Source

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

Set an example of a valid value.

Source

pub fn search_paths( self, paths: impl IntoIterator<Item = impl Into<PathBuf>>, ) -> Self

Set config search paths.

Source

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

Set the environment variable value.

Source

pub fn permission( self, current: impl Into<String>, required: impl Into<String>, ) -> Self

Set permission mode info.

Source

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

Set the raw error message.

Source

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

Set a custom message.

Source

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

Add a caused-by entry.

Source

pub fn from_toml_error(self, error: &Error) -> Self

Set location from a toml parse error.

Source

pub fn from_io_error(self, error: &Error) -> Self

Set location from an IO error.

Source

pub fn to_error_panel(&self) -> ErrorPanel

Convert to an ErrorPanel for rendering.

Source

pub fn render(&self, ctx: OutputContext)

Render the error to stderr.

Source

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

Serialize to JSON string.

Source

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

Serialize to compact JSON string.

Trait Implementations§

Source§

impl Clone for ConfigErrorDisplay

Source§

fn clone(&self) -> ConfigErrorDisplay

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 ConfigErrorDisplay

Source§

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

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

impl<'de> Deserialize<'de> for ConfigErrorDisplay

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 ConfigErrorDisplay

Source§

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

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

impl Error for ConfigErrorDisplay

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 ConfigErrorDisplay

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>,