frontmatter_gen::error

Enum Error

Source
#[non_exhaustive]
pub enum Error {
Show 20 variants ContentTooLarge { size: usize, max: usize, }, NestingTooDeep { depth: usize, max: usize, }, YamlParseError { source: Arc<Error>, }, TomlParseError(Error), JsonParseError(Arc<Error>), InvalidFormat, ConversionError(String), ParseError(String), UnsupportedFormat { line: usize, }, NoFrontmatterFound, InvalidJson, InvalidUrl(String), InvalidToml, InvalidYaml, InvalidLanguage(String), JsonDepthLimitExceeded, ExtractionError(String), SerdeError { source: Arc<Error>, }, ValidationError(String), Other(String),
}
Expand description

Represents errors that can occur during front matter operations.

This enumeration uses the thiserror crate to provide structured error messages, improving the ease of debugging and handling errors encountered in front matter processing.

Each variant represents a specific type of error that may occur during front matter operations, with appropriate context and error details.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

ContentTooLarge

Content exceeds the maximum allowed size.

This error occurs when the content size is larger than the configured maximum limit.

§Fields

  • size - The actual size of the content
  • max - The maximum allowed size

Fields

§size: usize

The actual size of the content

§max: usize

The maximum allowed size

§

NestingTooDeep

Nesting depth exceeds the maximum allowed.

This error occurs when the structure’s nesting depth is greater than the configured maximum depth.

Fields

§depth: usize

The actual nesting depth

§max: usize

The maximum allowed depth

§

YamlParseError

Error occurred whilst parsing YAML content.

This error occurs when the YAML parser encounters invalid syntax or structure.

Fields

§source: Arc<Error>

The original error from the YAML parser

§

TomlParseError(Error)

Error occurred whilst parsing TOML content.

This error occurs when the TOML parser encounters invalid syntax or structure.

§

JsonParseError(Arc<Error>)

Error occurred whilst parsing JSON content.

This error occurs when the JSON parser encounters invalid syntax or structure.

§

InvalidFormat

The front matter format is invalid or unsupported.

This error occurs when the front matter format cannot be determined or is not supported by the library.

§

ConversionError(String)

Error occurred during conversion between formats.

This error occurs when converting front matter from one format to another fails.

§

ParseError(String)

Generic error during parsing.

This error occurs when a parsing operation fails with a generic error.

§

UnsupportedFormat

Unsupported or unknown front matter format was detected.

This error occurs when an unsupported front matter format is encountered at a specific line.

Fields

§line: usize

The line number where the unsupported format was encountered

§

NoFrontmatterFound

No front matter content was found.

This error occurs when attempting to extract front matter from content that does not contain any front matter section.

§

InvalidJson

Invalid JSON front matter.

This error occurs when the JSON front matter is malformed or invalid.

§

InvalidUrl(String)

Invalid URL format.

This error occurs when an invalid URL is encountered in the front matter.

§

InvalidToml

Invalid TOML front matter.

This error occurs when the TOML front matter is malformed or invalid.

§

InvalidYaml

Invalid YAML front matter.

This error occurs when the YAML front matter is malformed or invalid.

§

InvalidLanguage(String)

Invalid language code.

This error occurs when an invalid language code is encountered in the front matter.

§

JsonDepthLimitExceeded

JSON front matter exceeds maximum nesting depth.

This error occurs when the JSON front matter structure exceeds the maximum allowed nesting depth.

§

ExtractionError(String)

Error during front matter extraction.

This error occurs when there is a problem extracting front matter from the content.

§

SerdeError

Serialization or deserialization error.

This error occurs when there is a problem serializing or deserializing content.

Fields

§source: Arc<Error>

The original error from the serde library

§

ValidationError(String)

Input validation error.

This error occurs when the input fails validation checks.

§

Other(String)

Generic error with a custom message.

This error occurs when a generic error is encountered with a custom message.

Implementations§

Source§

impl Error

Source

pub const fn category(&self) -> Category

Returns the category of the error.

§Returns

Returns the Category that best describes this error.

Source

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::Error;

let error = Error::generic_parse_error("Invalid syntax");
assert!(matches!(error, Error::ParseError(_)));
Source

pub const 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::Error;

let error = Error::unsupported_format(42);
assert!(matches!(error, Error::UnsupportedFormat { line: 42 }));
Source

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::Error;

let error = Error::validation_error("Invalid character in title");
assert!(matches!(error, Error::ValidationError(_)));
Source

pub fn with_context(self, context: &Context) -> Self

Adds context to an error.

§Arguments
  • context - Additional context information about the error.
§Examples
use frontmatter_gen::error::{Error, Context};

let context = Context {
    line: Some(42),
    column: Some(10),
    snippet: Some("invalid content".to_string()),
};

let error = Error::ParseError("Invalid syntax".to_string())
    .with_context(&context);

Trait Implementations§

Source§

impl Clone for Error

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<EngineError> for Error

Converts an EngineError into an Error.

This allows engine errors to be converted into front matter errors when needed, preserving the error context and message.

§Examples

use frontmatter_gen::error::{EngineError, Error};
use std::io;

let engine_error = EngineError::ContentError("content processing failed".to_string());
let frontmatter_error: Error = engine_error.into();
assert!(matches!(frontmatter_error, Error::ParseError(_)));
Source§

fn from(err: EngineError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Converts an IO error (std::io::Error) into a front matter Error.

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for String

Converts a front matter Error into a string.

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl !UnwindSafe for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<I> IntoResettable<String> for I
where I: Into<String>,

§

fn into_resettable(self) -> Resettable<String>

Convert to the intended resettable type
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T