Skip to content

Commit

Permalink
Fix error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenn committed Jan 7, 2024
1 parent 7f31aac commit 4717969
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/lexer/sql/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ impl fmt::Display for Error {
Error::MalformedHexInteger(pos) => {
write!(f, "malformed hex integer at {:?}", pos.unwrap())
}
Error::ParserError(ref msg, pos) => write!(f, "{} at {:?}", msg, pos.unwrap()),
Error::ParserError(ref msg, Some(pos)) => write!(f, "{} at {:?}", msg, pos),
Error::ParserError(ref msg, _) => write!(f, "{}", msg),
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/lexer/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,10 @@ impl<'input> FallibleIterator for Parser<'input> {
}
let cmd = self.parser.ctx.cmd();
if let Some(ref cmd) = cmd {
cmd.check()?;
if let Err(e) = cmd.check() {
let err = Error::ParserError(e, Some((self.scanner.line(), self.scanner.column())));
return Err(err);
}
}
Ok(cmd)
}
Expand Down

0 comments on commit 4717969

Please sign in to comment.