Enum bash_builtins::Error [−][src]
Expand description
The error type for Builtin::call
.
Usually, you don’t need to construct this type manually. Instead, use the
?
operator for any Result
in the body of the Builtin::call
method, and errors will be converted to this type.
However, if you want to return a specific exit code, use the
ExitCode
variant.
Variants
Syntax error in usage.
Exit with a specific code.
Example
use bash_builtins::{Args, Builtin, Error::ExitCode, Result}; impl Builtin for SomeName { fn call(&mut self, args: &mut Args) -> Result<()> { // In this builtin, we return `127` if there are // no arguments. if args.is_empty() { return Err(ExitCode(127)); } // … Ok(()) } }
Tuple Fields of ExitCode
0: c_int
Wrapper for any error.
This variant is used when the builtin propagates any error inside
Builtin::call
.
Example
use std::fs; use bash_builtins::{Args, Builtin, Error::ExitCode, Result}; impl Builtin for SomeName { fn call(&mut self, args: &mut Args) -> Result<()> { // fs::read can return an `io::Error`, which is wrapped // by `GenericError` and then used as the return value. let _ = fs::read("/some/config/file")?; // … Ok(()) } }