pub enum WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> {
Show 47 variants
GenericError,
DuplicatedCreature(CI),
DuplicatedObject(OI),
DuplicatedTeam(TI),
TeamNotFound(TI),
CreatureNotFound(CI),
ObjectNotFound(OI),
NewCreatureUnaccepted(TI, Box<Self>),
ConvertedCreatureUnaccepted(TI, CI, Box<Self>),
InvalidCreatureConversion(TI, CI),
TeamNotEmpty(TI),
PositionError(Option<PI>, PI, Box<Self>),
EntityNotFound(EI),
NonContiguousEventId(EventId, EventId),
TurnInProgress,
NoTurnInProgress,
ActorNotEligible(EI),
ActorNotReady(EI),
AbilityNotKnown(EI, AI),
AbilityNotActivable(EI, AI, Box<Self>),
TeamNotReady(TI),
PowerNotKnown(TI, WI),
PowerNotInvocable(TI, WI, Box<Self>),
StatusNotPresent(EI, SI),
EmptyEventProcessor,
NotACharacter(EI),
NotAnActor(EI),
NotACreature(EI),
NotAnObject(EI),
KinshipRelation,
SelfRelation,
IncompatibleVersions(V, V),
BattleEnded,
WrongMetricType(MI),
ConditionUnsatisfied,
DuplicatedEventSink(EventSinkId),
InvalidEventRange(Range<EventId>, EventId),
EventSinkNotFound(EventSinkId),
AuthenticationError(Option<PlayerId>, TI),
MissingAuthentication,
ServerOnlyEvent,
UserEventPackingError(E, String),
UserEventUnpackingError(String),
InvalidEvent(E, Box<Self>),
MultiError(Vec<Self>),
UserError(String),
EventSinkError(String),
}
Expand description
Error type for all kind of errors generated by weasel.
Variants§
GenericError
A generic error.
DuplicatedCreature(CI)
Duplicated creature id.
DuplicatedObject(OI)
Duplicated object id.
DuplicatedTeam(TI)
Duplicated team id.
TeamNotFound(TI)
The team doesn’t exist.
CreatureNotFound(CI)
The creature doesn’t exist.
ObjectNotFound(OI)
The object doesn’t exist.
NewCreatureUnaccepted(TI, Box<Self>)
Creation of creatures is disabled.
ConvertedCreatureUnaccepted(TI, CI, Box<Self>)
The creature can’t be transferred to the team.
InvalidCreatureConversion(TI, CI)
This creature conversion is not valid.
TeamNotEmpty(TI)
The team is not empty.
PositionError(Option<PI>, PI, Box<Self>)
Position is invalid.
EntityNotFound(EI)
The entity doesn’t exist.
NonContiguousEventId(EventId, EventId)
The event id is not contiguous.
TurnInProgress
A turn is already in progress.
NoTurnInProgress
No turn is in progress.
ActorNotEligible(EI)
The actor can’t start a new turn.
ActorNotReady(EI)
The actor can’t act at the moment.
AbilityNotKnown(EI, AI)
The actor doesn’t know such ability.
AbilityNotActivable(EI, AI, Box<Self>)
The ability can’t be activated.
TeamNotReady(TI)
The team can’t act at the moment.
PowerNotKnown(TI, WI)
The team doesn’t possess such power.
PowerNotInvocable(TI, WI, Box<Self>)
The power can’t be invoked.
StatusNotPresent(EI, SI)
Status not present on a character.
EmptyEventProcessor
The event processor is not valid.
NotACharacter(EI)
The entity is not a character.
NotAnActor(EI)
The entity is not an actor.
NotACreature(EI)
The entity is not a creature.
NotAnObject(EI)
The entity is not an object.
KinshipRelation
Attempt to set Relation::Kin
.
SelfRelation
Attempt to set relation towards oneself.
IncompatibleVersions(V, V)
Two versions of the battle rules are incompatible.
BattleEnded
The battle has already ended.
WrongMetricType(MI)
The metric’s type is not correct.
ConditionUnsatisfied
The EventPrototype
’s condition is not satisfied.
DuplicatedEventSink(EventSinkId)
Duplicated event sink id.
InvalidEventRange(Range<EventId>, EventId)
The event range is invalid.
EventSinkNotFound(EventSinkId)
The event sink doesn’t exist.
AuthenticationError(Option<PlayerId>, TI)
The player can’t fire the event.
MissingAuthentication
No authentication in the event.
ServerOnlyEvent
Event can be fired only be the server.
UserEventPackingError(E, String)
Failure while packing an user event into a UserEventPacker
.
UserEventUnpackingError(String)
Failure while unpacking a UserEventPacker
into an user event.
InvalidEvent(E, Box<Self>)
The event is invalid.
MultiError(Vec<Self>)
An error containing multiple inner errors.
UserError(String)
An user defined error.
EventSinkError(String)
A generic event sink error.
Implementations§
Source§impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>
impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>
Sourcepub fn unfold(self) -> Self
pub fn unfold(self) -> Self
Unfolds an error, return the inner one in case the original is an InvalidEvent
.
If not, it returns the original.
In the case of MultiError
, unfolds all contained errors.
§Examples
use weasel::{
battle_rules, error::WeaselErrorType, event::DummyEvent, rules::empty::*, BattleRules,
EventTrigger, WeaselError,
};
battle_rules! {}
let mut processor = ();
let trigger = DummyEvent::trigger(&mut processor);
let error: WeaselErrorType<CustomRules> =
WeaselError::InvalidEvent(trigger.event(), Box::new(WeaselError::EmptyEventProcessor));
assert_eq!(error.unfold(), WeaselError::EmptyEventProcessor);
Sourcepub fn filter<F>(self, op: F) -> Result<(), Self>
pub fn filter<F>(self, op: F) -> Result<(), Self>
Consumes this error and filters it with the given filter
function.
filter
is applied to this error, to the error inside InvalidEvent
and to all errors contained by MultiError
.
Only the errors for which filter
returns true are kept.
§Examples
use weasel::{
battle_rules, error::WeaselErrorType, event::DummyEvent, rules::empty::*, BattleRules,
EventTrigger, WeaselError,
};
battle_rules! {}
let mut processor = ();
let trigger = DummyEvent::trigger(&mut processor);
let error: WeaselErrorType<CustomRules> =
WeaselError::InvalidEvent(trigger.event(), Box::new(WeaselError::EmptyEventProcessor));
assert_eq!(
error
.filter(|err| {
if let WeaselError::EmptyEventProcessor = err {
false
} else {
true
}
})
.err(),
None
);
Trait Implementations§
Source§impl<V: Clone, TI: Clone, EI: Clone, CI: Clone, OI: Clone, PI: Clone, AI: Clone, WI: Clone, SI: Clone, MI: Clone, E: Clone> Clone for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>
impl<V: Clone, TI: Clone, EI: Clone, CI: Clone, OI: Clone, PI: Clone, AI: Clone, WI: Clone, SI: Clone, MI: Clone, E: Clone> Clone for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>
Source§fn clone(&self) -> WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>
fn clone(&self) -> WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<V: Debug, TI: Debug, EI: Debug, CI: Debug, OI: Debug, PI: Debug, AI: Debug, WI: Debug, SI: Debug, MI: Debug, E: Debug> Debug for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>
impl<V: Debug, TI: Debug, EI: Debug, CI: Debug, OI: Debug, PI: Debug, AI: Debug, WI: Debug, SI: Debug, MI: Debug, E: Debug> Debug for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>
Source§impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> Display for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>
impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> Display for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>
Source§impl<V: PartialEq, TI: PartialEq, EI: PartialEq, CI: PartialEq, OI: PartialEq, PI: PartialEq, AI: PartialEq, WI: PartialEq, SI: PartialEq, MI: PartialEq, E: PartialEq> PartialEq for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>
impl<V: PartialEq, TI: PartialEq, EI: PartialEq, CI: PartialEq, OI: PartialEq, PI: PartialEq, AI: PartialEq, WI: PartialEq, SI: PartialEq, MI: PartialEq, E: PartialEq> PartialEq for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>
Source§fn eq(
&self,
other: &WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>,
) -> bool
fn eq( &self, other: &WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>, ) -> bool
self
and other
values to be equal, and is used by ==
.