Skip to content

Commit

Permalink
🚸 (parser): Improve error messages
Browse files Browse the repository at this point in the history
semver: patch
  • Loading branch information
Somfic committed Jun 13, 2024
1 parent 9344a7d commit 51a4070
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/parser/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn parse(
.ok_or(Diagnostic::error(
cursor,
range.length,
format!("Cannot create an expression from {}", token.token_type),
"Expected a new expression",
))?;

let (mut left_hand_side, new_cursor) = expression_handler(parser, cursor)?;
Expand Down
15 changes: 5 additions & 10 deletions src/parser/typing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,11 @@ pub fn parse(
) -> Result<(Type, usize), Diagnostic> {
let mut cursor = cursor;
let (token, range) = expect_valid_token!(parser, cursor);
let type_handler =
parser
.lookup
.type_lookup
.get(&token.token_type)
.ok_or(Diagnostic::error(
cursor,
range.length,
format!("Cannot create a type from {}", token.token_type),
))?;
let type_handler = parser
.lookup
.type_lookup
.get(&token.token_type)
.ok_or(Diagnostic::error(cursor, range.length, "Expected a type"))?;

let (mut left_hand_side, new_cursor) = type_handler(parser, cursor)?;

Expand Down

0 comments on commit 51a4070

Please sign in to comment.