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

pub enum WeaselError<V, TI, EI, CI, PI, AI, MI, E> {
    DuplicatedCreature(CI),
    DuplicatedTeam(TI),
    TeamNotFound(TI),
    CreatureNotFound(CI),
    NewCreatureUnaccepted(TI),
    ConvertedCreatureUnaccepted(TI, CI),
    InvalidCreatureConversion(TI, CI),
    PositionError(Option<PI>, PI),
    EntityNotFound(EI),
    NonContiguousEventId(EventIdEventId),
    RoundInProgress,
    NoRoundInProgress,
    ActorNotEligible(EI),
    ActorNotReady(EI),
    AbilityNotKnown(EI, AI),
    AbilityNotActivable(EI, AI),
    EmptyEventProcessor,
    NotACharacter(EI),
    NotAnActor(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<WeaselError<V, TI, EI, CI, PI, AI, MI, E>>),
    MultiError(Vec<WeaselError<V, TI, EI, CI, PI, AI, MI, E>>),
    UserError(String),
    EventSinkError(String),
}

Error type for all kind of errors generated by weasel.

Variants

DuplicatedCreature(CI)

Duplicated creature id.

DuplicatedTeam(TI)

Duplicated team id.

TeamNotFound(TI)

The team doesn't exist.

CreatureNotFound(CI)

The creature doesn't exist.

NewCreatureUnaccepted(TI)

Creation of creatures is disabled.

ConvertedCreatureUnaccepted(TI, CI)

The creature can't be transferred to the team.

InvalidCreatureConversion(TI, CI)

This creature conversion is not valid.

PositionError(Option<PI>, PI)

Position is invalid.

EntityNotFound(EI)

The entity doesn't exist.

NonContiguousEventId(EventIdEventId)

The event id is not contiguous.

RoundInProgress

A round is already in progress.

NoRoundInProgress

No round is in progress.

ActorNotEligible(EI)

The actor can't start a new round.

ActorNotReady(EI)

The actor can't act at the moment.

AbilityNotKnown(EI, AI)

Actor does not know such ability.

AbilityNotActivable(EI, AI)

The ability can't be activated.

EmptyEventProcessor

The event processor is not valid.

NotACharacter(EI)

The entity is not a character.

NotAnActor(EI)

The entity is not an actor.

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<WeaselError<V, TI, EI, CI, PI, AI, MI, E>>)

The event is invalid.

MultiError(Vec<WeaselError<V, TI, EI, CI, PI, AI, MI, E>>)

An error containing multiple inner errors.

UserError(String)

An user defined error.

EventSinkError(String)

A generic event sink error.

Methods

impl<V, TI, EI, CI, PI, AI, MI, E> WeaselError<V, TI, EI, CI, PI, AI, 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::event::{EventTrigger, DummyEvent};
use weasel::error::{WeaselErrorType, WeaselError};
use weasel::battle::BattleRules;
use weasel::{battle_rules, rules::empty::*};

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::event::{EventTrigger, DummyEvent};
use weasel::error::{WeaselErrorType, WeaselError};
use weasel::battle::BattleRules;
use weasel::{battle_rules, rules::empty::*};

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, PI: Clone, AI: Clone, MI: Clone, E: Clone> Clone for WeaselError<V, TI, EI, CI, PI, AI, MI, E>[src]

impl<V: Debug, TI: Debug, EI: Debug, CI: Debug, PI: Debug, AI: Debug, MI: Debug, E: Debug> Debug for WeaselError<V, TI, EI, CI, PI, AI, MI, E>[src]

impl<V, TI, EI, CI, PI, AI, MI, E> Display for WeaselError<V, TI, EI, CI, PI, AI, MI, E> where
    V: Debug,
    TI: Debug,
    EI: Debug,
    CI: Debug,
    PI: Debug,
    AI: Debug,
    MI: Debug,
    E: Debug
[src]

impl<V, TI, EI, CI, PI, AI, MI, E> Error for WeaselError<V, TI, EI, CI, PI, AI, MI, E> where
    V: Debug,
    TI: Debug,
    EI: Debug,
    CI: Debug,
    PI: Debug,
    AI: Debug,
    MI: Debug,
    E: Debug
[src]

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

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

Auto Trait Implementations

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

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

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

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

impl<V, TI, EI, CI, PI, AI, MI, E> UnwindSafe for WeaselError<V, TI, EI, CI, PI, AI, MI, E> where
    AI: UnwindSafe,
    CI: UnwindSafe,
    E: UnwindSafe,
    EI: UnwindSafe,
    MI: UnwindSafe,
    PI: UnwindSafe,
    TI: UnwindSafe,
    V: 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>,