use thiserror::Error;
use crate::ConstString;
use super::BehaviorState;
#[derive(Error, Debug)]
pub enum Error {
#[error("the item {name} is already registered")]
AlreadyRegistered {
name: ConstString,
},
#[error("behavior composition error: {txt}")]
Composition {
txt: ConstString,
},
#[error("a 'blackboard' error occured: {0}")]
Databoard(#[from] databoard::Error),
#[error("a 'port' error occured: {0}")]
Dataport(#[from] dataport::Error),
#[error("a deserialization error occured: {0}")]
Nanoserde(#[from] nanoserde::DeJsonErr),
#[error("the attribute '{value}' is no pre or post condition")]
NoCondition {
value: ConstString,
},
#[error("value {value} is not a boolean type")]
NotABool {
value: ConstString,
},
#[error("could not parse value '{value}' in {src}")]
ParseError {
value: ConstString,
src: ConstString,
},
#[error("could not parse int value: {0}")]
ParseInt(#[from] core::num::ParseIntError),
#[error("could not parse value for port {port} into specified type {typ}")]
ParsePortValue {
port: ConstString,
typ: ConstString,
},
#[error("port {port} is not declared in behavior {behavior}")]
PortNotDeclared {
port: ConstString,
behavior: ConstString,
},
#[error("a scripting error occured: {0}")]
Scripting(#[from] tinyscript::Error),
#[error("child node of {behavior} returned state {state} when not allowed")]
State {
behavior: ConstString,
state: BehaviorState,
},
#[error("unable to set the pre or post condition {value})")]
UnableToSetCondition {
value: ConstString,
},
}