use crate::error::{ErrorKind, YamlError};
pub struct DirectiveErrors;
impl DirectiveErrors {
pub fn duplicate_yaml_directive() -> YamlError {
YamlError::new(ErrorKind::ParseError, "Duplicate YAML directive")
}
pub fn missing_yaml_version() -> YamlError {
YamlError::new(
ErrorKind::ParseError,
"Missing YAML version after %YAML directive",
)
}
pub fn invalid_yaml_major_version_generic() -> YamlError {
YamlError::new(ErrorKind::ParseError, "Invalid YAML major version")
}
pub fn invalid_yaml_minor_version_generic() -> YamlError {
YamlError::new(ErrorKind::ParseError, "Invalid YAML minor version")
}
pub fn invalid_yaml_major_version_num(major: u8) -> YamlError {
YamlError::new(
ErrorKind::ParseError,
alloc::format!("Invalid YAML major version: {}", major),
)
}
pub fn malformed_tag_directive() -> YamlError {
YamlError::new(
ErrorKind::ParseError,
"YAML compliance error: Malformed %TAG directive. Expected format: %TAG <handle> <prefix>",
)
}
pub fn undefined_tag_handle(handle: &str) -> YamlError {
YamlError::new(
ErrorKind::ParseError,
alloc::format!(
"Undefined tag handle '{}'. Define it with a %TAG directive",
handle
),
)
}
pub fn must_be_followed_by_document_msg() -> &'static str {
"Directive must be followed by a document"
}
pub fn directives_not_allowed_midstream_msg() -> &'static str {
"Directives are not allowed after content unless the previous document ended with '...'"
}
}