just/src/compile_error_kind.rs
Casey Rodarmor 1b0fafea75
Add loader and refactor errors (#917)
This commit adds a `Loader` type, which can be used to load multiple
source strings. This was done to support the work on modules, but
coincidentally enabled consolidating errors, since now `Config::run`
can take a `&Loader`, and in the event of an error, return and `Error`
that borrows from loaded strings. Multiple error types have been
consolidated, and a bunch of ad-hoc error printing was removed.
2021-07-26 01:26:06 -07:00

117 lines
2.2 KiB
Rust

use crate::common::*;
#[derive(Debug, PartialEq)]
pub(crate) enum CompileErrorKind<'src> {
AliasShadowsRecipe {
alias: &'src str,
recipe_line: usize,
},
BacktickShebang,
CircularRecipeDependency {
recipe: &'src str,
circle: Vec<&'src str>,
},
CircularVariableDependency {
variable: &'src str,
circle: Vec<&'src str>,
},
DependencyArgumentCountMismatch {
dependency: &'src str,
found: usize,
min: usize,
max: usize,
},
DeprecatedEquals,
DuplicateAlias {
alias: &'src str,
first: usize,
},
DuplicateParameter {
recipe: &'src str,
parameter: &'src str,
},
DuplicateRecipe {
recipe: &'src str,
first: usize,
},
DuplicateSet {
setting: &'src str,
first: usize,
},
DuplicateVariable {
variable: &'src str,
},
ExpectedKeyword {
expected: Vec<Keyword>,
found: &'src str,
},
ExtraLeadingWhitespace,
FunctionArgumentCountMismatch {
function: &'src str,
found: usize,
expected: usize,
},
InconsistentLeadingWhitespace {
expected: &'src str,
found: &'src str,
},
Internal {
message: String,
},
InvalidEscapeSequence {
character: char,
},
MismatchedClosingDelimiter {
close: Delimiter,
open: Delimiter,
open_line: usize,
},
MixedLeadingWhitespace {
whitespace: &'src str,
},
ParameterFollowsVariadicParameter {
parameter: &'src str,
},
ParameterShadowsVariable {
parameter: &'src str,
},
RequiredParameterFollowsDefaultParameter {
parameter: &'src str,
},
UndefinedVariable {
variable: &'src str,
},
UnexpectedCharacter {
expected: char,
},
UnexpectedClosingDelimiter {
close: Delimiter,
},
UnexpectedEndOfToken {
expected: char,
},
UnexpectedToken {
expected: Vec<TokenKind>,
found: TokenKind,
},
UnknownAliasTarget {
alias: &'src str,
target: &'src str,
},
UnknownDependency {
recipe: &'src str,
unknown: &'src str,
},
UnknownFunction {
function: &'src str,
},
UnknownSetting {
setting: &'src str,
},
UnknownStartOfToken,
UnpairedCarriageReturn,
UnterminatedBacktick,
UnterminatedInterpolation,
UnterminatedString,
}