start unifying error messages
This commit is contained in:
parent
a25b6d1e92
commit
283155c38b
2 changed files with 29 additions and 29 deletions
|
@ -17,21 +17,21 @@ use crate::{
|
|||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum InterpreterError {
|
||||
#[error("[line {0}] MINUS unary expression expects a number on the right")]
|
||||
#[error("line {0}: MINUS unary expression expects a number on the right")]
|
||||
UnaryExpressionNotANumber(usize),
|
||||
#[error("[line {0}] unknown unary operator: {1}")]
|
||||
#[error("line {0}: unknown unary operator: {1}")]
|
||||
UnaryOperatorUnknown(usize, String),
|
||||
#[error("[line {0}] unknown binary operator: {1}")]
|
||||
#[error("line {0}: unknown binary operator: {1}")]
|
||||
BinaryOperatorUnknown(usize, String),
|
||||
#[error("[line {0}] left or right is not a number.")]
|
||||
#[error("line {0}: left or right is not a number.")]
|
||||
BinaryExpressionNeedsNumber(usize),
|
||||
#[error("[line {0}] left or right is neither a number nor string.")]
|
||||
#[error("line {0}: left or right is neither a number nor string.")]
|
||||
BinaryExpressionNeedsNumberOrString(usize),
|
||||
#[error("{0}")]
|
||||
UndefinedVariable(EnvironmentError),
|
||||
#[error("[line {0}] {1} is not callable.")]
|
||||
#[error("line {0}: {1} is not callable.")]
|
||||
NotACallable(usize, Value),
|
||||
#[error("[line {0}] {1}.")]
|
||||
#[error("line {0}: {1}.")]
|
||||
FailedToCall(usize, CallingError),
|
||||
}
|
||||
|
||||
|
|
|
@ -13,49 +13,49 @@ use tracing::error;
|
|||
pub enum ParserError {
|
||||
#[error("empty token stream")]
|
||||
NoTokens,
|
||||
#[error("[line {0}] expected expression")]
|
||||
#[error("line {0}: expected expression")]
|
||||
ExpressionExpected(usize),
|
||||
#[error("[line {0}] expected ')' after expression.")]
|
||||
#[error("line {0}: expected ')' after expression.")]
|
||||
ParenAfterExpression(usize),
|
||||
#[error("[Out of bounds access at index {0}.")]
|
||||
#[error("Out of bounds access at index {0}.")]
|
||||
OutOfBoundsAccess(usize),
|
||||
#[error("[line {0}] literal expected.")]
|
||||
#[error("line {0}: literal expected.")]
|
||||
LiteralExpected(usize),
|
||||
#[error("[line {0}] expected ';' after value.")]
|
||||
#[error("line {0}: expected ';' after value.")]
|
||||
SemicolonAfterValueExpected(usize),
|
||||
#[error("[line {0}] expected ';' after expression.")]
|
||||
#[error("line {0}: expected ';' after expression.")]
|
||||
SemicolonAfterExpressionExpected(usize),
|
||||
#[error("[line {0}] expected variable name.")]
|
||||
#[error("line {0}: expected variable name.")]
|
||||
VariableNameExpected(usize),
|
||||
#[error("[line {0}] invalid assignment target.")]
|
||||
#[error("line {0}: invalid assignment target.")]
|
||||
InvalidAssignmentTarget(usize),
|
||||
#[error("[line {0}] expected '}}' after block.")]
|
||||
#[error("line {0}: expected '}}' after block.")]
|
||||
RightBraceAfterBlockExpected(usize),
|
||||
#[error("[line {0}] expected '(' after if.")]
|
||||
#[error("line {0}: expected '(' after if.")]
|
||||
LeftParenAfterIfExpected(usize),
|
||||
#[error("[line {0}] expected ')' after condition.")]
|
||||
#[error("line {0}: expected ')' after condition.")]
|
||||
RightParenAfterConditionExpected(usize),
|
||||
#[error("[line {0}] expected '(' after while.")]
|
||||
#[error("line {0}: expected '(' after while.")]
|
||||
LeftParenAfterWhileExpected(usize),
|
||||
#[error("[line {0}] expected '(' after for.")]
|
||||
#[error("line {0}: expected '(' after for.")]
|
||||
LeftParenAfterForExpected(usize),
|
||||
#[error("[line {0}] expected ';' after loop condition.")]
|
||||
#[error("line {0}: expected ';' after loop condition.")]
|
||||
SemicolonAfterLoopConditionExpected(usize),
|
||||
#[error("[line {0}] expected ')' after for clauses.")]
|
||||
#[error("line {0}: expected ')' after for clauses.")]
|
||||
RightParenAfterForClausesExpected(usize),
|
||||
#[error("[line {0}] expected ')' after arguments.")]
|
||||
#[error("line {0}: expected ')' after arguments.")]
|
||||
RightParenAfterArgumentsExpected(usize),
|
||||
#[error("[line {0}] expected function name.")]
|
||||
#[error("line {0}: expected function name.")]
|
||||
FunctionNameExpected(usize),
|
||||
#[error("[line {0}] expected '(' after function name.")]
|
||||
#[error("line {0}: expected '(' after function name.")]
|
||||
LeftParenAfterFunctionNameExpected(usize),
|
||||
#[error("[line {0}] expected ')' after parameters.")]
|
||||
#[error("line {0}: expected ')' after parameters.")]
|
||||
RightParenAfterParamsExpected(usize),
|
||||
#[error("[line {0}] expected parameter name.")]
|
||||
#[error("line {0}: expected parameter name.")]
|
||||
ParamNameExpected(usize),
|
||||
#[error("[line {0}] expected '{{' before function body.")]
|
||||
#[error("line {0}: expected '{{' before function body.")]
|
||||
LeftBraceBeforeFunctionBodyExpected(usize),
|
||||
#[error("[line {0}] expected ';' after return value.")]
|
||||
#[error("line {0}: expected ';' after return value.")]
|
||||
SemicolonAfterReturnExpected(usize),
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue