pub struct CommandError { /* private fields */ }Expand description
An error that a command callback returns to stop resolution.
Resolution then fails with ResolveError::Command, which carries the
message, and the failed call is recorded with CommandOutcome::Error.
The Display output is the message.
§Examples
A callback that refuses commands it does not know:
use adotenv::{parse_strict, CommandError, ExpandOptions, ResolveError};
let doc = parse_strict("TOKEN=$(cat /run/secrets/token)\n")?;
let failure = doc
.resolve_with_commands(
|_| None,
|context| Err(CommandError::new(format!("not allowed: {}", context.command))),
None,
&ExpandOptions::dotenv_expand(),
)
.unwrap_err();
assert!(matches!(
failure.error,
ResolveError::Command { key, message, .. }
if key == "TOKEN" && message == "not allowed: cat /run/secrets/token"
));Implementations§
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
impl Display for CommandError
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)>
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()
Source§impl Mask for CommandError
impl Mask for CommandError
Source§impl PartialEq for CommandError
impl PartialEq for CommandError
impl StructuralPartialEq for CommandError
Auto Trait Implementations§
impl Forget for CommandError
impl Freeze for CommandError
impl Move for CommandError
impl RefUnwindSafe for CommandError
impl Send for CommandError
impl Sync for CommandError
impl Unpin for CommandError
impl UnsafeUnpin for CommandError
impl UnwindSafe for CommandError
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