Skip to main content

Module error

Module error 

Source
Expand description

Shared error types used across parsing, config loading, and formatting. Structured error types returned by parsing, config loading, and formatting.

Every fallible crate API returns Result, which is std::result::Result<T, Error>. The Error enum distinguishes sources:

  • Error::Parse — CMake source failed to parse; line/column info is 1-based.
  • Error::Config — a .cmakefmt.yaml|yml|toml (or from_yaml_str input) failed to deserialise, or a programmatic crate::Config had an invalid regex pattern.
  • Error::Spec — a commands: override file (or string) failed to deserialise, or the built-in spec file itself did.
  • Error::Io — filesystem or stream I/O failure.
  • Error::Formatter — higher-level formatter or CLI failure that doesn’t fit another variant.
  • Error::LayoutTooWideonly produced when crate::Config::require_valid_layout is enabled and a formatted line exceeded the configured width. Not a bug in the formatter — a signal to the caller.

crate::error::FileParseError and crate::error::ParseDiagnostic carry structured line/column metadata (1-based, both) so editor integrations can point at the offending source without re-parsing the error string.

Structs§

ConfigError
Stable config-file parse error returned by the public library API.
FileParseError
Structured config/spec deserialization failure metadata used for user-facing diagnostics.
ParseDiagnostic
Crate-owned parser diagnostics used by Error without exposing pest internals in the public API.
ParseError
Stable parse error returned by the public library API.
SpecError
Stable command-spec parse error returned by the public library API.

Enums§

Error
Errors that can be returned by parsing, config loading, spec loading, or formatting operations.

Traits§

IoResultExt
Extension trait for ergonomic conversion of io::Result<T> into the crate’s path-bearing Result<T>. Reads at call sites as std::fs::read_to_string(&path).with_path(&path)? — one extra token compared to .map_err(Error::Io)?, with much better diagnostics on failure.

Type Aliases§

Result
Convenience alias for crate-level results.