mirror of
https://github.com/uutils/coreutils
synced 2024-12-14 23:32:39 +00:00
df: error handling cleanup
This commit is contained in:
parent
72b0ba0b05
commit
388e14f208
1 changed files with 5 additions and 18 deletions
|
@ -14,6 +14,7 @@ mod table;
|
||||||
use blocks::HumanReadable;
|
use blocks::HumanReadable;
|
||||||
use table::HeaderMode;
|
use table::HeaderMode;
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
|
use uucore::error::FromIo;
|
||||||
use uucore::error::{UError, UIoError, UResult, USimpleError};
|
use uucore::error::{UError, UIoError, UResult, USimpleError};
|
||||||
use uucore::fsext::{read_fs_list, MountInfo};
|
use uucore::fsext::{read_fs_list, MountInfo};
|
||||||
use uucore::parse_size::ParseSizeError;
|
use uucore::parse_size::ParseSizeError;
|
||||||
|
@ -443,15 +444,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
// Get the list of filesystems to display in the output table.
|
// Get the list of filesystems to display in the output table.
|
||||||
let filesystems: Vec<Filesystem> = match matches.values_of(OPT_PATHS) {
|
let filesystems: Vec<Filesystem> = match matches.values_of(OPT_PATHS) {
|
||||||
None => {
|
None => {
|
||||||
let filesystems = match get_all_filesystems(&opt) {
|
let filesystems = get_all_filesystems(&opt)
|
||||||
Ok(filesystems) => filesystems,
|
.map_err_context(|| "cannot read table of mounted file systems".into())?;
|
||||||
Err(error) => {
|
|
||||||
return Err(UIoError::new(
|
|
||||||
error.kind(),
|
|
||||||
"cannot read table of mounted file systems",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if filesystems.is_empty() {
|
if filesystems.is_empty() {
|
||||||
return Err(USimpleError::new(1, "no file systems processed"));
|
return Err(USimpleError::new(1, "no file systems processed"));
|
||||||
|
@ -461,15 +455,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
Some(paths) => {
|
Some(paths) => {
|
||||||
let paths: Vec<&str> = paths.collect();
|
let paths: Vec<&str> = paths.collect();
|
||||||
let filesystems = match get_named_filesystems(&paths, &opt) {
|
let filesystems = get_named_filesystems(&paths, &opt)
|
||||||
Ok(filesystems) => filesystems,
|
.map_err_context(|| "cannot read table of mounted file systems".into())?;
|
||||||
Err(error) => {
|
|
||||||
return Err(UIoError::new(
|
|
||||||
error.kind(),
|
|
||||||
"cannot read table of mounted file systems",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// This can happen if paths are given as command-line arguments
|
// This can happen if paths are given as command-line arguments
|
||||||
// but none of the paths exist.
|
// but none of the paths exist.
|
||||||
|
|
Loading…
Reference in a new issue