pub enum FrontmatterError {
Show 18 variants
ContentTooLarge {
size: usize,
max: usize,
},
NestingTooDeep {
depth: usize,
max: usize,
},
YamlParseError {
source: Error,
},
TomlParseError(Error),
JsonParseError(Error),
InvalidFormat,
ConversionError(String),
ParseError(String),
UnsupportedFormat {
line: usize,
},
NoFrontmatterFound,
InvalidJson,
InvalidToml,
InvalidYaml,
InvalidUrl(String),
InvalidLanguage(String),
JsonDepthLimitExceeded,
ExtractionError(String),
ValidationError(String),
}Expand description
Represents errors that can occur during frontmatter operations.
This enum uses the thiserror crate to provide structured error messages,
improving the ease of debugging and handling errors encountered in
frontmatter processing.
Variants§
ContentTooLarge
Content exceeds the maximum allowed size
NestingTooDeep
Nesting depth exceeds the maximum allowed
YamlParseError
Error occurred while parsing YAML content
TomlParseError(Error)
Error occurred while parsing TOML content
JsonParseError(Error)
Error occurred while parsing JSON content
InvalidFormat
The frontmatter format is invalid or unsupported
ConversionError(String)
Error occurred during conversion between formats
ParseError(String)
Generic error during parsing
UnsupportedFormat
Unsupported or unknown frontmatter format was detected
NoFrontmatterFound
No frontmatter content was found
InvalidJson
Invalid JSON frontmatter
InvalidToml
Invalid TOML frontmatter
InvalidYaml
Invalid YAML frontmatter
InvalidUrl(String)
Invalid URL format
InvalidLanguage(String)
Invalid language code
JsonDepthLimitExceeded
JSON frontmatter exceeds maximum nesting depth
ExtractionError(String)
Error during frontmatter extraction
ValidationError(String)
Input validation error
Implementations§
Source§impl FrontmatterError
impl FrontmatterError
Sourcepub fn generic_parse_error(message: &str) -> Self
pub fn generic_parse_error(message: &str) -> Self
Creates a generic parse error with a custom message.
§Arguments
message- A string slice containing the error message
§Examples
use frontmatter_gen::error::FrontmatterError;
let error = FrontmatterError::generic_parse_error("Invalid syntax");
assert!(matches!(error, FrontmatterError::ParseError(_)));Sourcepub fn unsupported_format(line: usize) -> Self
pub fn unsupported_format(line: usize) -> Self
Creates an unsupported format error for a specific line.
§Arguments
line- The line number where the unsupported format was detected
§Examples
use frontmatter_gen::error::FrontmatterError;
let error = FrontmatterError::unsupported_format(42);
assert!(matches!(error, FrontmatterError::UnsupportedFormat { line: 42 }));Sourcepub fn validation_error(message: &str) -> Self
pub fn validation_error(message: &str) -> Self
Creates a validation error with a custom message.
§Arguments
message- A string slice containing the validation error message
§Examples
use frontmatter_gen::error::FrontmatterError;
let error = FrontmatterError::validation_error("Invalid character in title");
assert!(matches!(error, FrontmatterError::ValidationError(_)));