diff options
| author | Bert Belder <bertbelder@gmail.com> | 2020-08-26 00:22:15 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-26 00:22:15 +0200 |
| commit | 9bfb0df805719cb3f022a5b5d9f9d898ae954c2e (patch) | |
| tree | 6c7d62d95fcbde54ebbe1035bdc74618c63cfbc0 /cli/fmt.rs | |
| parent | d0ccab7fb7dd80030d3765ca9a9af44de6ecda5a (diff) | |
refactor: remove OpError, use ErrBox everywhere (#7187)
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/fmt.rs')
| -rw-r--r-- | cli/fmt.rs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/cli/fmt.rs b/cli/fmt.rs index 319f7fece..b81573294 100644 --- a/cli/fmt.rs +++ b/cli/fmt.rs @@ -10,7 +10,6 @@ use crate::colors; use crate::diff::diff; use crate::fs::files_in_subtree; -use crate::op_error::OpError; use crate::text_encoding; use deno_core::ErrBox; use dprint_plugin_typescript as dprint; @@ -110,14 +109,11 @@ async fn check_source_files( if not_formatted_files_count == 0 { Ok(()) } else { - Err( - OpError::other(format!( - "Found {} not formatted {}", - not_formatted_files_count, - files_str(not_formatted_files_count), - )) - .into(), - ) + Err(ErrBox::error(format!( + "Found {} not formatted {}", + not_formatted_files_count, + files_str(not_formatted_files_count), + ))) } } @@ -175,7 +171,7 @@ async fn format_source_files( fn format_stdin(check: bool) -> Result<(), ErrBox> { let mut source = String::new(); if stdin().read_to_string(&mut source).is_err() { - return Err(OpError::other("Failed to read from stdin".to_string()).into()); + return Err(ErrBox::error("Failed to read from stdin")); } let formatter = dprint::Formatter::new(get_config()); @@ -191,7 +187,7 @@ fn format_stdin(check: bool) -> Result<(), ErrBox> { } } Err(e) => { - return Err(OpError::other(e).into()); + return Err(ErrBox::error(e)); } } Ok(()) @@ -217,7 +213,9 @@ fn is_supported(path: &Path) -> bool { } } -pub fn collect_files(files: Vec<String>) -> Result<Vec<PathBuf>, ErrBox> { +pub fn collect_files( + files: Vec<String>, +) -> Result<Vec<PathBuf>, std::io::Error> { let mut target_files: Vec<PathBuf> = vec![]; if files.is_empty() { |
