mirror of
https://github.com/str4d/rage.git
synced 2025-04-04 19:37:51 +03:00
rage: Give a better error message when a recipients file is missing
This commit is contained in:
parent
ff68ec4e0a
commit
dbdd34a91f
4 changed files with 13 additions and 2 deletions
|
@ -138,6 +138,8 @@ err-enc-invalid-recipients-file =
|
|||
err-enc-missing-recipients = Missing recipients.
|
||||
rec-enc-missing-recipients = Did you forget to specify {-flag-recipient}?
|
||||
|
||||
err-enc-missing-recipients-file = Recipients file not found: {$filename}
|
||||
|
||||
err-enc-mixed-identity-passphrase = {-flag-identity} can't be used with {-flag-passphrase}.
|
||||
err-enc-mixed-recipient-passphrase = {-flag-recipient} can't be used with {-flag-passphrase}.
|
||||
err-enc-mixed-recipients-file-passphrase = {-flag-recipients-file} can't be used with {-flag-passphrase}.
|
||||
|
|
|
@ -35,6 +35,7 @@ pub(crate) enum EncryptError {
|
|||
},
|
||||
Io(io::Error),
|
||||
MissingRecipients,
|
||||
MissingRecipientsFile(String),
|
||||
MixedIdentityAndPassphrase,
|
||||
MixedRecipientAndPassphrase,
|
||||
MixedRecipientsFileAndPassphrase,
|
||||
|
@ -100,6 +101,11 @@ impl fmt::Display for EncryptError {
|
|||
wlnfl!(f, "err-enc-missing-recipients")?;
|
||||
wfl!(f, "rec-enc-missing-recipients")
|
||||
}
|
||||
EncryptError::MissingRecipientsFile(filename) => wfl!(
|
||||
f,
|
||||
"err-enc-missing-recipients-file",
|
||||
filename = filename.as_str(),
|
||||
),
|
||||
EncryptError::MixedIdentityAndPassphrase => {
|
||||
wfl!(f, "err-enc-mixed-identity-passphrase")
|
||||
}
|
||||
|
|
|
@ -151,7 +151,10 @@ fn read_recipients(
|
|||
}
|
||||
|
||||
for arg in recipients_file_strings {
|
||||
let f = File::open(&arg)?;
|
||||
let f = File::open(&arg).map_err(|e| match e.kind() {
|
||||
io::ErrorKind::NotFound => error::EncryptError::MissingRecipientsFile(arg.clone()),
|
||||
_ => e.into(),
|
||||
})?;
|
||||
let buf = BufReader::new(f);
|
||||
read_recipients_list(&arg, buf, &mut recipients, &mut plugin_recipients)?;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ status = "failed"
|
|||
stdin = ""
|
||||
stdout = ""
|
||||
stderr = """
|
||||
Error: No such file or directory (os error 2)
|
||||
Error: Recipients file not found: foobar.txt
|
||||
|
||||
[ Did rage not do what you expected? Could an error be more useful? ]
|
||||
[ Tell us: https://str4d.xyz/rage/report ]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue