feat(specctra-core/error): separate errors for expected leaf / end-of-list

This commit is contained in:
Alain Emilia Anna Zscheile 2024-12-06 15:10:56 +01:00 committed by mikolaj
parent 8a724dc5d2
commit 8fb9bfc0e6
2 changed files with 9 additions and 3 deletions

View File

@ -31,7 +31,7 @@ impl ListToken {
if let Self::Leaf { value } = self {
Ok(value)
} else {
Err(ParseError::Expected("leaf value"))
Err(ParseError::ExpectedLeaf)
}
}
@ -39,7 +39,7 @@ impl ListToken {
if let Self::End = self {
Ok(())
} else {
Err(ParseError::Expected("end of list"))
Err(ParseError::ExpectedEndOfList)
}
}

View File

@ -6,10 +6,16 @@ pub enum ParseError {
Eof,
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("expected {0}")]
Expected(&'static str),
#[error("expected ({0}")]
#[error("expected \"({0}\"")]
ExpectedStartOfList(&'static str),
#[error("expected \")\"")]
ExpectedEndOfList,
#[error("expected leaf value")]
ExpectedLeaf,
#[error("found a space inside a quoted string, but file didn't declare this possibility")]
UnexpectedSpaceInQuotedStr,
}