pub enum ErrorContext {
    Static,
    WithReactor,
    FullNoGlobal,
    Full,
}
Expand description

The context of an error, which determines what is available to your views. This must be checked before using things like translators, which may not be available, depending on the information in here.

Variants§

§

Static

Perseus has suffered an unrecoverable error in initialization, and routing/interactivity is impossible. Your error view will be rendered to the page, and then Perseus will terminate completely. This means any buttons, handlers, etc. will not run!

If you’re having trouble with this, imagine printing out your error view. That’s the amount of functionality you get (except that the browser will automatically take over any links). If you want interactivity, you could use dangerously_set_inner_html to create some JS handlers, for instance for offering the user a button to reload the page.

§

WithReactor

Perseus suffered an error before it was able to create a translator. Your error view will be rendered inside a proper router, and you’ll have a Reactor available in context, but using the t! or link! macros will lead to a panic. If you present links to other pages in the app, the user will be able to press them, and these will try to set up a translator, but this may fail.

If your app doesn’t use internationalization, Perseus does still have a dummy translator internally, so this doesn’t completely evaporate, but you can ignore it.

Note: currently, if the user goes to, say /en-US/this-page-does-not-exist, even though the page is clearly localized, Perseus will not provide a translator. This will be rectified in a future version. If the user attempted to switch locales, and there was an error fetching translations for the new one, the old translator will be provided here.

§

FullNoGlobal

Perseus was able to successfully instantiate a reactor and translator, but this error view is being rendered on the engine-side, and there is no global state available.

Although global state could theoretically be provided to error pages sometimes, the complexity and cloning involved make this extremely nuanced (e.g. exported error pages can’t access localized global state because they don’t know their locale, global state might be only partially built at the time of the error, etc.). In general, error views rendered on the engine-side will have this (though not always).

§

Full

Perseus was able to successfully instantiate everything, including a translator, but then it encountered an error. You have access to all the usual things you would have in a page here.

Note that this would also be given to you on the engine-side when you have a translator available, but when you’re still rendering to an [SsrNode].

Trait Implementations§

source§

impl Clone for ErrorContext

source§

fn clone(&self) -> ErrorContext

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ErrorContext

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Copy for ErrorContext

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.