Expand description
Error handling for the frontmatter-gen crate.
This module provides a comprehensive set of error types to handle various failure scenarios that may occur during front matter parsing, conversion, and extraction operations. Each error variant includes detailed error messages and context to aid in debugging and error handling.
§Error Handling Strategies
The error system provides several ways to handle errors:
- Context-aware errors: Use
Context
to add line/column information - Categorized errors: Group errors by type using
Category
- Error conversion: Convert from standard errors using
From
implementations - Rich error messages: Detailed error descriptions with context
§Features
- Type-safe error handling with descriptive messages
- Support for YAML, TOML, and JSON parsing errors
- Content validation errors with size and depth checks
- Format-specific error handling
- Extraction and conversion error handling
§Examples
use frontmatter_gen::error::Error;
fn example() -> Result<(), Error> {
// Example of handling YAML parsing errors
let invalid_yaml = "invalid: : yaml";
match serde_yml::from_str::<serde_yml::Value>(invalid_yaml) {
Ok(_) => Ok(()),
Err(e) => Err(Error::YamlParseError { source: e.into() }),
}
}
Structs§
- Provides additional context for front matter errors.
Enums§
- Categories of front matter errors.
- Errors that can occur during site generation.
- Represents errors that can occur during front matter operations.