feat: generalize error InvalidFunction -> UnrecognizedName
This commit is contained in:
parent
33862c602d
commit
7f733c1053
1 changed files with 6 additions and 4 deletions
|
|
@ -6,8 +6,8 @@ use crate::nodes::{Node, Nodes, PREC};
|
|||
|
||||
#[derive(Clone, Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
#[error("invalid function: {0}")]
|
||||
InvalidFunction(String),
|
||||
#[error("unrecognized function/constant: {0}")]
|
||||
UnrecognizedName(String),
|
||||
#[error("invalid operator: {0}")]
|
||||
InvalidOperator(char),
|
||||
#[error("failed to parse number '{0}': {1}")]
|
||||
|
|
@ -66,7 +66,9 @@ impl FromStr for Nodes {
|
|||
ParsingState::ReadingFunctionName(start_index) => {
|
||||
if !c.is_alphabetic() {
|
||||
nodes.push(Node::from_name(&filtered_string[start_index..i]).map_err(
|
||||
|()| Error::InvalidFunction(filtered_string[start_index..i].to_owned()),
|
||||
|()| {
|
||||
Error::UnrecognizedName(filtered_string[start_index..i].to_owned())
|
||||
},
|
||||
)?);
|
||||
|
||||
state = ParsingState::Start;
|
||||
|
|
@ -117,7 +119,7 @@ impl FromStr for Nodes {
|
|||
ParsingState::ReadingFunctionName(start_index) => {
|
||||
nodes.push(
|
||||
Node::from_name(&filtered_string[start_index..i]).map_err(|()| {
|
||||
Error::InvalidFunction(filtered_string[start_index..i].to_owned())
|
||||
Error::UnrecognizedName(filtered_string[start_index..i].to_owned())
|
||||
})?,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue