Enum perseus::errors::ClientError
source · pub enum ClientError {
Panic(String),
PluginError(PluginError),
InvariantError(ClientInvariantError),
ThawError(ClientThawError),
ServerError {
status: u16,
message: String,
},
FetchError(FetchError),
PlatformError(ClientPlatformError),
PreloadError(ClientPreloadError),
}
Expand description
Errors that can occur in the browser.
Important: any changes to this enum
constitute a breaking change,
since users match this in their error pages. Changes in underlying
enum
s are not considered breaking (e.g. introducing a new invariant
error).
Warning: in all these cases, except ClientError::ServerError
, the user
can already see the prerendered version of the page, it just isn’t
interactive. Only in that case will your error page occupy the entire
screen, otherwise it will be placed into a div
with the class
__perseus-error
, a deliberate choice to reinforce the best practice of
giving the user as much as possible (it might not be interactive, but they
can still use a rudimentary version). See the book for further details.
Panic handling
In a rather unorthodox manner, Perseus will do its level best to get an
error message to the user of your app, no matter what happens. For this
reason, this enum
includes a Panic
variant that will be provided when a
panic has been intercepted. In this case, your error view will be rendered
with no reactor, translations, or anything else available to it. What you do
at this time is extremely important, since any panics in the code that
handles that variant cannot be caught, leaving the user with no error
message and an app that has completely frozen.
The Panic
variant on this type only provides a formatted panic message,
and nothing else from std::panic::PanicInfo
, due to lifetime
constraints. Since the message formatting is done by the standard library,
which automatically takes account of the payload
and message
, the only
other properties are location
and can_unwind
: the latter should be
handled by Perseus if it ever is, and the former shoudl not be exposed to
end users. Currently, there is no way to get the underlying PanicInfo
through Perseus’ error handling system (although a plugin could do it
by overriding the panic handler, but this is usually a bad idea).