pub enum StdlibError {
WrongArgCount {
function: String,
expected: usize,
got: usize,
},
TypeMismatch {
function: String,
position: usize,
expected: String,
got: String,
},
AssertionFailed {
message: String,
},
UnknownFunction {
module: String,
function: String,
},
RuntimeError(String),
CapabilityCall {
module: String,
function: String,
cap_id: u32,
fn_id: u32,
args: Vec<Value>,
},
}Expand description
Errors that can occur when calling stdlib functions.
Variants§
WrongArgCount
Wrong number of arguments passed to a function.
TypeMismatch
Argument has the wrong type.
AssertionFailed
core.assert failed.
UnknownFunction
Unknown function in module.
RuntimeError(String)
Generic runtime error (e.g., NaN would be produced, division by zero).
CapabilityCall
Capability call — cannot be executed locally, must be routed to host.
The caller should use cap_id and fn_id for env.host_call dispatch.
Implementations§
Source§impl StdlibError
impl StdlibError
Sourcepub fn wrong_args(function: &str, expected: usize, got: usize) -> Self
pub fn wrong_args(function: &str, expected: usize, got: usize) -> Self
Create a WrongArgCount error.
Sourcepub fn type_mismatch(
function: &str,
position: usize,
expected: &str,
got: &str,
) -> Self
pub fn type_mismatch( function: &str, position: usize, expected: &str, got: &str, ) -> Self
Create a TypeMismatch error.
Sourcepub fn unknown_function(module: &str, function: &str) -> Self
pub fn unknown_function(module: &str, function: &str) -> Self
Create an UnknownFunction error.
Trait Implementations§
Source§impl Clone for StdlibError
impl Clone for StdlibError
Source§fn clone(&self) -> StdlibError
fn clone(&self) -> StdlibError
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StdlibError
impl Debug for StdlibError
Source§impl Display for StdlibError
impl Display for StdlibError
Source§impl Error for StdlibError
impl Error for StdlibError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl !RefUnwindSafe for StdlibError
impl !UnwindSafe for StdlibError
impl Freeze for StdlibError
impl Send for StdlibError
impl Sync for StdlibError
impl Unpin for StdlibError
impl UnsafeUnpin for StdlibError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more