Skip to content

Commit b91a32c

Browse files
committed
refactor: avoid thiserror::Error imports
1 parent 5c5b46f commit b91a32c

49 files changed

Lines changed: 52 additions & 99 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/uu/cat/src/cat.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use std::io::{self, BufWriter, ErrorKind, IsTerminal, Read, Write};
1717
use std::os::fd::AsFd;
1818
#[cfg(unix)]
1919
use std::os::unix::fs::FileTypeExt;
20-
use thiserror::Error;
2120
use uucore::display::Quotable;
2221
use uucore::error::{UResult, strip_errno};
2322
use uucore::translate;
@@ -79,7 +78,7 @@ impl LineNumber {
7978
}
8079
}
8180

82-
#[derive(Error, Debug)]
81+
#[derive(Debug, thiserror::Error)]
8382
enum CatError {
8483
/// Wrapper around `io::Error`
8584
#[error("{}", strip_errno(.0))]

src/uu/chcon/src/errors.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ use std::ffi::OsString;
99
use std::fmt::Write;
1010
use std::io;
1111

12-
use thiserror::Error;
1312
use uucore::display::Quotable;
1413
use uucore::translate;
1514

1615
pub(crate) type Result<T> = std::result::Result<T, Error>;
1716

18-
#[derive(Error, Debug)]
17+
#[derive(Debug, thiserror::Error)]
1918
pub(crate) enum Error {
2019
#[error("{}", translate!("chcon-error-no-context-specified"))]
2120
MissingContext,

src/uu/chmod/src/chmod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use std::ffi::OsString;
1010
use std::fs;
1111
use std::os::unix::fs::{MetadataExt, PermissionsExt};
1212
use std::path::{Path, PathBuf};
13-
use thiserror::Error;
1413
use uucore::display::Quotable;
1514
use uucore::error::{ExitCode, UError, UResult, USimpleError, UUsageError, set_exit_code};
1615
use uucore::fs::display_permissions_unix;
@@ -23,7 +22,7 @@ use uucore::{format_usage, show, show_error};
2322

2423
use uucore::translate;
2524

26-
#[derive(Debug, Error)]
25+
#[derive(Debug, thiserror::Error)]
2726
enum ChmodError {
2827
#[error("{}", translate!("chmod-error-cannot-stat", "file" => _0.quote()))]
2928
CannotStat(PathBuf),

src/uu/chroot/src/error.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
use std::ffi::OsString;
88
use std::io::Error;
99
use std::path::PathBuf;
10-
use thiserror::Error;
1110
use uucore::display::Quotable;
1211
use uucore::error::UError;
1312
use uucore::libc;
1413
use uucore::translate;
1514

1615
/// Errors that can happen while executing chroot.
17-
#[derive(Debug, Error)]
16+
#[derive(Debug, thiserror::Error)]
1817
pub enum ChrootError {
1918
/// Failed to enter the specified directory.
2019
#[error("{}", translate!("chroot-error-cannot-enter", "dir" => _0.quote(), "err" => _1))]

src/uu/cp/src/cp.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use filetime::FileTime;
2424
use indicatif::{ProgressBar, ProgressStyle};
2525
#[cfg(unix)]
2626
use nix::sys::stat::{Mode, SFlag, dev_t, mknod as nix_mknod, mode_t};
27-
use thiserror::Error;
2827

2928
use platform::copy_on_write;
3029
use uucore::display::Quotable;
@@ -50,7 +49,7 @@ use crate::copydir::copy_directory;
5049
mod copydir;
5150
mod platform;
5251

53-
#[derive(Debug, Error)]
52+
#[derive(Debug, thiserror::Error)]
5453
pub enum CpError {
5554
/// Simple [`io::Error`] wrapper
5655
#[error("{0}")]

src/uu/csplit/src/csplit_error.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
// file that was distributed with this source code.
55

66
use std::io;
7-
use thiserror::Error;
87
use uucore::display::Quotable;
98
use uucore::error::UError;
109
use uucore::translate;
1110

1211
/// Errors thrown by the csplit command
13-
#[derive(Debug, Error)]
12+
#[derive(Debug, thiserror::Error)]
1413
pub enum CsplitError {
1514
#[error("IO error: {}", _0)]
1615
IoError(#[from] io::Error),

src/uu/dd/src/parseargs.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ mod unit_tests;
99

1010
use super::{ConversionMode, IConvFlags, IFlags, Num, OConvFlags, OFlags, Settings, StatusLevel};
1111
use crate::conversion_tables::ConversionTable;
12-
use thiserror::Error;
1312
use uucore::display::Quotable;
1413
use uucore::error::UError;
1514
use uucore::parser::parse_size::{ParseSizeError, Parser as SizeParser};
1615
use uucore::show_warning;
1716
use uucore::translate;
1817

1918
/// Parser Errors describe errors with parser input
20-
#[derive(Debug, PartialEq, Eq, Error)]
19+
#[derive(Debug, PartialEq, Eq, thiserror::Error)]
2120
pub enum ParseError {
2221
#[error("{}", translate!("dd-error-unrecognized-operand", "operand" => .0.clone()))]
2322
UnrecognizedOperand(String),

src/uu/df/src/columns.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// spell-checker:ignore itotal iused iavail ipcent pcent squashfs
66
use crate::{OPT_INODES, OPT_OUTPUT, OPT_PRINT_TYPE};
77
use clap::{ArgMatches, parser::ValueSource};
8-
use thiserror::Error;
98
use uucore::display::Quotable;
109

1110
/// The columns in the output table produced by `df`.
@@ -58,7 +57,7 @@ pub(crate) enum Column {
5857
}
5958

6059
/// An error while defining which columns to display in the output table.
61-
#[derive(Debug, Error)]
60+
#[derive(Debug, thiserror::Error)]
6261
pub(crate) enum ColumnError {
6362
/// If a column appears more than once in the `--output` argument.
6463
#[error("{}", .0.quote())]

src/uu/df/src/df.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use clap::{Arg, ArgAction, ArgMatches, Command, parser::ValueSource};
2323
use std::ffi::OsString;
2424
use std::io::stdout;
2525
use std::path::Path;
26-
use thiserror::Error;
2726

2827
use crate::blocks::{BlockSize, read_block_size};
2928
use crate::columns::{Column, ColumnError};
@@ -118,7 +117,7 @@ impl Options {
118117
}
119118
}
120119

121-
#[derive(Debug, Error)]
120+
#[derive(Debug, thiserror::Error)]
122121
enum OptionsError {
123122
// TODO This needs to vary based on whether `--block-size`
124123
// or `-B` were provided.
@@ -429,7 +428,7 @@ where
429428
Ok(result)
430429
}
431430

432-
#[derive(Debug, Error)]
431+
#[derive(Debug, thiserror::Error)]
433432
enum DfError {
434433
/// A problem while parsing command-line options.
435434
#[error("{}", .0)]

src/uu/du/src/du.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use std::path::{Path, PathBuf};
2020
use std::str::FromStr;
2121
use std::sync::mpsc;
2222
use std::thread;
23-
use thiserror::Error;
2423
use uucore::display::{Quotable, print_verbatim};
2524
use uucore::error::{FromIo, UError, UResult, USimpleError, set_exit_code};
2625
use uucore::fsext::{MetadataTimeField, metadata_get_time};
@@ -737,7 +736,7 @@ fn du_regular(
737736
Ok(my_stat)
738737
}
739738

740-
#[derive(Debug, Error)]
739+
#[derive(Debug, thiserror::Error)]
741740
enum DuError {
742741
#[error("{}", translate!("du-error-invalid-max-depth", "depth" => _0.quote()))]
743742
InvalidMaxDepthArg(String),

0 commit comments

Comments
 (0)