pub struct CommandError { /* private fields */ }Expand description
A failure returned by a command function. When Err is returned, the VM returns it from run as a runtime error (the
VM adds the position).
The core has no error messages. It holds only codes and arguments; turning them into messages is the host’s job (the CLI uses FTL).
Implementations§
Source§impl CommandError
impl CommandError
Sourcepub fn with_code<I>(code: impl Into<String>, args: I) -> Self
pub fn with_code<I>(code: impl Into<String>, args: I) -> Self
Makes a failure with a code and named arguments. The code is package.error_name (such as
input.integer_out_of_range).
Argument values are DiagArgs (strings or integers; can be made with .into()). Pass decimals as strings.
Sourcepub fn arg(self, name: &'static str, value: impl Into<DiagArg>) -> Self
pub fn arg(self, name: &'static str, value: impl Into<DiagArg>) -> Self
Adds one named argument (used instead of passing an array to with_code when value types are mixed).
Sourcepub fn integer_overflow() -> Self
pub fn integer_overflow() -> Self
Integer overflow.
Sourcepub fn non_finite_float() -> Self
pub fn non_finite_float() -> Self
A float result became NaN or ±∞.
Sourcepub fn float_out_of_range() -> Self
pub fn float_out_of_range() -> Self
A float does not fit in the range of int.
Sourcepub fn division_by_zero() -> Self
pub fn division_by_zero() -> Self
Divided by 0.
Sourcepub fn interrupted() -> Self
pub fn interrupted() -> Self
The command stopped because an interrupt was requested (Ctx::interrupted).
Sourcepub fn kind(&self) -> &CommandErrorKind
pub fn kind(&self) -> &CommandErrorKind
The kind of failure.
Trait Implementations§
Source§impl Clone for CommandError
impl Clone for CommandError
Source§impl Debug for CommandError
impl Debug for CommandError
Source§impl Display for CommandError
In the form code (name=value, …) (for logs; not a message for users).
impl Display for CommandError
In the form code (name=value, …) (for logs; not a message for users).
impl Eq for CommandError
Source§impl Error for CommandError
impl Error for CommandError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()