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

Expose the fields of Error as public #369

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Changes from all commits
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
20 changes: 19 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub enum ErrorType {
Io(std::io::Error),
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub enum InternalError {
TapeError,
}
Expand Down Expand Up @@ -183,6 +183,24 @@ impl Error {
error: t,
}
}

/// Returns the byte index the error occurred at.
#[must_use]
pub fn index(&self) -> usize {
self.index
}

/// Returns the current character the error occurred at.
#[must_use]
pub fn character(&self) -> Option<char> {
self.character
}

/// Returns the type of error that occurred.
#[must_use]
pub fn error(&self) -> &ErrorType {
&self.error
}
}
impl std::error::Error for Error {}

Expand Down
Loading