|
7 | 7 | use std::ffi::OsString; |
8 | 8 | use thiserror::Error; |
9 | 9 | use uucore::display::Quotable; |
10 | | -use uucore::error::UError; |
| 10 | +use uucore::error::{UError, strip_errno}; |
11 | 11 | use uucore::translate; |
12 | 12 |
|
13 | 13 | #[derive(Debug, Error)] |
14 | 14 | pub enum TacError { |
15 | 15 | /// A regular expression given by the user is invalid. |
16 | 16 | #[error("{}", translate!("tac-error-invalid-regex", "error" => .0))] |
17 | 17 | InvalidRegex(regex::Error), |
18 | | - /// The argument to tac is a directory. |
19 | | - #[error("{}", translate!("tac-error-invalid-directory-argument", "argument" => .0.maybe_quote()))] |
20 | | - InvalidDirectoryArgument(OsString), |
21 | | - /// The specified file is not found on the filesystem. |
22 | | - #[error("{}", translate!("tac-error-file-not-found", "filename" => .0.quote()))] |
23 | | - FileNotFound(OsString), |
| 18 | + /// An error opening a file for reading. |
| 19 | + /// |
| 20 | + /// The parameters are the name of the file and the underlying |
| 21 | + /// [`std::io::Error`] that caused this error. |
| 22 | + #[error("{}", translate!("tac-error-open-error", "filename" => .0.quote(), "error" => strip_errno(.1)))] |
| 23 | + OpenError(OsString, std::io::Error), |
24 | 24 | /// An error reading the contents of a file or stdin. |
25 | 25 | /// |
26 | 26 | /// The parameters are the name of the file and the underlying |
27 | 27 | /// [`std::io::Error`] that caused this error. |
28 | | - #[error("{}", translate!("tac-error-read-error", "filename" => .0.quote(), "error" => .1))] |
| 28 | + #[error("{}", translate!("tac-error-read-error", "filename" => .0.maybe_quote(), "error" => strip_errno(.1)))] |
29 | 29 | ReadError(OsString, std::io::Error), |
30 | 30 | /// An error writing the (reversed) contents of a file or stdin. |
31 | 31 | /// |
32 | 32 | /// The parameter is the underlying [`std::io::Error`] that caused |
33 | 33 | /// this error. |
34 | | - #[error("{}", translate!("tac-error-write-error", "error" => .0))] |
| 34 | + #[error("{}", translate!("tac-error-write-error", "error" => strip_errno(.0)))] |
35 | 35 | WriteError(std::io::Error), |
36 | 36 | } |
37 | 37 |
|
|
0 commit comments