Improve error messages with additional colons (#1319)

This commit is contained in:
Lorrens Pantelis 2024-06-22 00:26:23 +02:00 committed by GitHub
parent 79af31b672
commit f16c1afed0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 144 additions and 144 deletions

View file

@ -3116,7 +3116,7 @@ impl<'a> Parser<'a> {
/// Report `found` was encountered instead of `expected`
pub fn expected<T>(&self, expected: &str, found: TokenWithLocation) -> Result<T, ParserError> {
parser_err!(
format!("Expected {expected}, found: {found}"),
format!("Expected: {expected}, found: {found}"),
found.location
)
}
@ -11581,7 +11581,7 @@ mod tests {
assert_eq!(
ast,
Err(ParserError::TokenizerError(
"Unterminated string literal at Line: 1, Column 5".to_string()
"Unterminated string literal at Line: 1, Column: 5".to_string()
))
);
}
@ -11593,7 +11593,7 @@ mod tests {
assert_eq!(
ast,
Err(ParserError::ParserError(
"Expected [NOT] NULL or TRUE|FALSE or [NOT] DISTINCT FROM after IS, found: a at Line: 1, Column 16"
"Expected: [NOT] NULL or TRUE|FALSE or [NOT] DISTINCT FROM after IS, found: a at Line: 1, Column: 16"
.to_string()
))
);

View file

@ -429,7 +429,7 @@ impl fmt::Display for Location {
write!(
f,
// TODO: use standard compiler location syntax (<path>:<line>:<col>)
" at Line: {}, Column {}",
" at Line: {}, Column: {}",
self.line, self.column,
)
}
@ -1816,7 +1816,7 @@ mod tests {
use std::error::Error;
assert!(err.source().is_none());
}
assert_eq!(err.to_string(), "test at Line: 1, Column 1");
assert_eq!(err.to_string(), "test at Line: 1, Column: 1");
}
#[test]