use core::{
num::{ParseFloatError, ParseIntError},
str::ParseBoolError,
};
use thiserror::Error;
use crate::ConstString;
#[derive(Error, Debug, PartialEq)]
pub enum Error {
#[error("a port with that name is already in the collection")]
AlreadyExists,
#[error("port has a different data type then expected")]
DataType,
#[error("could not convert port value from 'str'")]
FromStr,
#[error("port is currently locked")]
IsLocked,
#[error("port '{name}' could not be found in the collection")]
NotFound {
name: ConstString,
},
#[error("no value set for port")]
NoValueSet,
#[error("port '{name}' could not be found in 'other' collection")]
OtherNotFound {
name: ConstString,
},
#[error("value for port could not be parsed")]
ParseValue,
#[error("port has an incompatible type")]
PortType,
#[error("port '{port}' returns '{value}' with a different type")]
ReturnTypeMismatch { port: ConstString, value: ConstString },
}
impl From<ParseBoolError> for Error {
fn from(_value: ParseBoolError) -> Self {
Self::ParseValue
}
}
impl From<ParseFloatError> for Error {
fn from(_value: ParseFloatError) -> Self {
Self::ParseValue
}
}
impl From<ParseIntError> for Error {
fn from(_value: ParseIntError) -> Self {
Self::ParseValue
}
}