#[non_exhaustive]pub enum Error {
Parse(ParseError),
Config(ConfigError),
Spec(SpecError),
Io(Error),
#[non_exhaustive] IoAt {
path: PathBuf,
source: Error,
},
Formatter(String),
#[non_exhaustive] CliArg {
message: String,
},
#[non_exhaustive] InvalidRegex {
pattern: String,
source: Error,
},
#[non_exhaustive] Render {
format: String,
message: String,
},
#[non_exhaustive] LegacyMigration {
path: PathBuf,
message: String,
},
#[non_exhaustive] LayoutTooWide {
line_no: usize,
width: usize,
limit: usize,
},
}Expand description
Errors that can be returned by parsing, config loading, spec loading, or formatting operations.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Parse(ParseError)
A parser error annotated with source text and line-offset context.
Config(ConfigError)
A user config parse error.
Spec(SpecError)
A built-in or user override spec parse error.
Io(Error)
A filesystem or stream I/O failure where no path is attached.
Use Error::io_at (or the IoResultExt::with_path adapter)
when reporting an error against a specific file — the
path-bearing variant is far more useful in user-facing
diagnostics.
#[non_exhaustive]IoAt
A filesystem I/O failure annotated with the path that caused
it. Used at every site where we have a path in scope; far more
actionable than a bare permission denied from Error::Io.
Fields
This variant is marked as non-exhaustive
Formatter(String)
A higher-level formatter or CLI error that does not fit another
structured variant. Prefer Error::CliArg, Error::InvalidRegex,
Error::Render, Error::LegacyMigration, or Error::IoAt
when the failure mode is one of those — Error::Formatter is the
catch-all for the small set of cases that legitimately don’t fit
any of those categories (e.g. LSP runtime failures, semantic
verification failures, watch-loop infrastructure, git subprocess
failures, spec parsing from in-memory strings without a path).
#[non_exhaustive]CliArg
A CLI argument validation failure — incompatible flag combinations, missing required arguments, conflicting overrides.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]InvalidRegex
A regex pattern from the user (CLI flag, config file, or spec override) failed to compile or apply.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]Render
A failure rendering a crate::Config or spec to text (TOML /
YAML / JSON), or building a machine-format report (SARIF /
Checkstyle / JUnit / JSON edit). The format field names the
target format.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]LegacyMigration
A failure during legacy cmake-format config migration —
parsing the old format, converting it, or writing the
modernised file. The path field carries the legacy file the
user was trying to migrate.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]LayoutTooWide
A formatted line exceeded the configured line width and
require_valid_layout is enabled.
Fields
This variant is marked as non-exhaustive
limit: usizeConfigured crate::Config::line_width limit.
Implementations§
Source§impl Error
impl Error
Sourcepub fn with_display_name(self, display_name: impl Into<String>) -> Self
pub fn with_display_name(self, display_name: impl Into<String>) -> Self
Attach a human-facing source name (e.g. a file path) to a
contextual ParseError. No-op for any other variant —
Config, Spec, Io, IoAt, Formatter, CliArg,
InvalidRegex, Render, LegacyMigration, and
LayoutTooWide already carry the context they need and are
returned unchanged.
Sourcepub fn io_at(path: impl Into<PathBuf>, source: Error) -> Self
pub fn io_at(path: impl Into<PathBuf>, source: Error) -> Self
Build an Error::IoAt variant from a path and an underlying
io::Error. Use this at every I/O call site where you have a
path in scope — Error::Io is reserved for streams (stdout,
stdin) and similar path-less I/O.
Sourcepub fn cli_arg(message: impl Into<String>) -> Self
pub fn cli_arg(message: impl Into<String>) -> Self
Build an Error::CliArg variant from a human-readable
description of the invalid argument combination.
Sourcepub fn invalid_regex(pattern: impl Into<String>, source: Error) -> Self
pub fn invalid_regex(pattern: impl Into<String>, source: Error) -> Self
Build an Error::InvalidRegex variant from the pattern that
failed to compile and the underlying regex::Error.
Sourcepub fn render(format: impl Into<String>, message: impl Into<String>) -> Self
pub fn render(format: impl Into<String>, message: impl Into<String>) -> Self
Build an Error::Render variant from the target format name
and a human-readable failure message.
Sourcepub fn legacy_migration(
path: impl Into<PathBuf>,
message: impl Into<String>,
) -> Self
pub fn legacy_migration( path: impl Into<PathBuf>, message: impl Into<String>, ) -> Self
Build an Error::LegacyMigration variant from the legacy
config path and a human-readable failure message.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()