[][src]Enum weasel::error::WeaselError

pub enum WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> {
    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(EventIdEventId),
    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),
}

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(EventIdEventId)

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

impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>[src]

pub fn unfold(self) -> Self[src]

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);

pub fn filter<F>(self, op: F) -> Result<(), Self> where
    F: Fn(&Self) -> bool + Copy
[src]

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

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>[src]

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>[src]

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> where
    V: Debug,
    TI: Debug,
    EI: Debug,
    CI: Debug,
    OI: Debug,
    PI: Debug,
    AI: Debug,
    WI: Debug,
    SI: Debug,
    MI: Debug,
    E: Debug
[src]

impl<V: PartialEq, TI: PartialEq, EI: PartialEq, CI: PartialEq, OI: PartialEq, PI: PartialEq, AI: PartialEq, WI: PartialEq, SI: PartialEq, MI: PartialEq, E: PartialEq> PartialEq<WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>> for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>[src]

impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> StructuralPartialEq for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>[src]

Auto Trait Implementations

impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> RefUnwindSafe for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> where
    AI: RefUnwindSafe,
    CI: RefUnwindSafe,
    E: RefUnwindSafe,
    EI: RefUnwindSafe,
    MI: RefUnwindSafe,
    OI: RefUnwindSafe,
    PI: RefUnwindSafe,
    SI: RefUnwindSafe,
    TI: RefUnwindSafe,
    V: RefUnwindSafe,
    WI: RefUnwindSafe

impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> Send for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> where
    AI: Send,
    CI: Send,
    E: Send,
    EI: Send,
    MI: Send,
    OI: Send,
    PI: Send,
    SI: Send,
    TI: Send,
    V: Send,
    WI: Send

impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> Sync for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> where
    AI: Sync,
    CI: Sync,
    E: Sync,
    EI: Sync,
    MI: Sync,
    OI: Sync,
    PI: Sync,
    SI: Sync,
    TI: Sync,
    V: Sync,
    WI: Sync

impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> Unpin for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> where
    AI: Unpin,
    CI: Unpin,
    E: Unpin,
    EI: Unpin,
    MI: Unpin,
    OI: Unpin,
    PI: Unpin,
    SI: Unpin,
    TI: Unpin,
    V: Unpin,
    WI: Unpin

impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> UnwindSafe for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> where
    AI: UnwindSafe,
    CI: UnwindSafe,
    E: UnwindSafe,
    EI: UnwindSafe,
    MI: UnwindSafe,
    OI: UnwindSafe,
    PI: UnwindSafe,
    SI: UnwindSafe,
    TI: UnwindSafe,
    V: UnwindSafe,
    WI: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,