pub enum PluginError {
Exception(GenericValue),
Fatal,
}Expand description
The error side of a plugin function: what should reach the generic VM when the function does not return normally.
An exact mirror of the two non-ok wire statuses
(FfiStatus::Exception / FfiStatus::Fatal).
Failed re-entering host calls hand back
PluginError::Exception (the raised exception instance) or
PluginError::Fatal; propagating them with ? re-raises the
exception with full identity - class, fields, and original stack trace
or forwards the fatal error, respectively. To throw a fresh
exception, use the typed constructors on Host
(host.type_error("…"), …), which create the instance eagerly; for
non-builtin classes, build the instance with
Host::make_exception (or by calling the class) and wrap it:
fn half(host: &mut Host, args: &[GenericValue]) -> Result<GenericValue, PluginError> {
let Some(n) = host.as_int(args[0]) else {
return Err(host.type_error("half expects an int"));
};
Ok(host.make_int(n / 2))
}Variants§
Exception(GenericValue)
An exception instance - freshly created, or caught from a re-entering host call - to be (re-)raised.
Fatal
A fatal host error passing through. Only ever forwarded; plugins must not fabricate it.
Trait Implementations§
Source§impl Clone for PluginError
impl Clone for PluginError
Source§fn clone(&self) -> PluginError
fn clone(&self) -> PluginError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more