Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make get_variable usable from outside the crate #16

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
undo changes on error.rs
  • Loading branch information
cre4ture committed Jan 10, 2024
commit 54b294365a353f8f7cac8d1a2b23e1b2f194cd0a
21 changes: 14 additions & 7 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! Module containing error details.

/// An error that can occur during variable substitution.
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone)]
#[cfg_attr(test, derive(Eq, PartialEq))]
pub enum Error {
/// The input string contains an invalid escape sequence.
InvalidEscapeSequence(InvalidEscapeSequence),
@@ -138,7 +139,8 @@ impl std::fmt::Display for CharOrByte {
}

/// The input string contains an invalid escape sequence.
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone)]
#[cfg_attr(test, derive(Eq, PartialEq))]
pub struct InvalidEscapeSequence {
/// The byte offset within the input where the error occurs.
///
@@ -168,7 +170,8 @@ impl std::fmt::Display for InvalidEscapeSequence {
}

/// The input string contains a variable placeholder without a variable name (`"${}"`).
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone)]
#[cfg_attr(test, derive(Eq, PartialEq))]
pub struct MissingVariableName {
/// The byte offset within the input where the error occurs.
///
@@ -189,7 +192,8 @@ impl std::fmt::Display for MissingVariableName {
}

/// The input string contains an unexpected character.
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone)]
#[cfg_attr(test, derive(Eq, PartialEq))]
pub struct UnexpectedCharacter {
/// The byte offset within the input where the error occurs.
///
@@ -221,7 +225,8 @@ impl std::fmt::Display for UnexpectedCharacter {
}

/// A struct to describe what was expected instead of the unexpected character.
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone)]
#[cfg_attr(test, derive(Eq, PartialEq))]
pub struct ExpectedCharacter {
/// A human readable message to describe what is expected.
pub(crate) message: &'static str,
@@ -236,7 +241,8 @@ impl ExpectedCharacter {
}

/// The input string contains an unclosed variable placeholder.
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone)]
#[cfg_attr(test, derive(Eq, PartialEq))]
pub struct MissingClosingBrace {
/// The byte offset within the input where the error occurs.
///
@@ -254,7 +260,8 @@ impl std::fmt::Display for MissingClosingBrace {
}

/// The input string contains a placeholder for a variable that is not in the variable map.
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone)]
#[cfg_attr(test, derive(Eq, PartialEq))]
pub struct NoSuchVariable {
/// The byte offset within the input where the error occurs.
///
Loading