Skip to content

Commit

Permalink
Include an error message in ParseError.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamirTalwar committed Feb 16, 2024
1 parent 5ecdbf1 commit c111384
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions rust-connector-sdk/src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub mod example;
#[derive(Debug, Error)]
pub enum ParseError {
#[error("error parsing configuration: {0}")]
ParseError(Position),
ParseError(LocatedError),
#[error("error validating configuration: {0}")]
ValidateError(InvalidPaths),
#[error("error processing configuration: {0}")]
Expand All @@ -29,20 +29,22 @@ pub enum ParseError {

/// The position of a single character in a text file.
#[derive(Debug, Clone)]
pub struct Position {
pub struct LocatedError {
pub path: PathBuf,
pub line: usize,
pub column: usize,
pub message: String,
}

impl Display for Position {
impl Display for LocatedError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{0}:{1}:{2}",
"{0}:{1}:{2}: {3}",
self.path.display(),
self.line,
self.column
self.column,
self.message
)
}
}
Expand Down

0 comments on commit c111384

Please sign in to comment.