diff options
| author | Tibo <delor.thibault@gmail.com> | 2018-04-26 13:48:48 +1000 |
|---|---|---|
| committer | Tibo <delor.thibault@gmail.com> | 2018-04-26 13:48:48 +1000 |
| commit | b7df23c3d5a3950ea6432acd71d34cd847a3be89 (patch) | |
| tree | b529bd2a741dce5af1dd0e71997da5cbb25771a3 /src/bin | |
| parent | 5581be26162fb34275538a7c4660b5f4e69a5d2a (diff) | |
Replace completely std::error with failure crate
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/main.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/bin/main.rs b/src/bin/main.rs index 453c7806d23..0ddf2f8c3df 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -11,6 +11,7 @@ #![cfg(not(test))] extern crate env_logger; +extern crate failure; extern crate getopts; extern crate rustfmt_nightly as rustfmt; @@ -19,6 +20,8 @@ use std::fs::File; use std::io::{self, stdout, Read, Write}; use std::path::PathBuf; +use failure::err_msg; + use getopts::{Matches, Options}; use rustfmt::{emit_post_matter, emit_pre_matter, load_config, CliOptions, Config, FmtResult, @@ -167,7 +170,7 @@ fn execute(opts: &Options) -> FmtResult<(WriteMode, Summary)> { Ok((WriteMode::None, Summary::default())) } Operation::ConfigOutputDefault { path } => { - let toml = Config::default().all_options().to_toml()?; + let toml = Config::default().all_options().to_toml().map_err(err_msg)?; if let Some(path) = path { let mut file = File::create(path)?; file.write_all(toml.as_bytes())?; @@ -186,7 +189,9 @@ fn execute(opts: &Options) -> FmtResult<(WriteMode, Summary)> { // parse file_lines if let Some(ref file_lines) = matches.opt_str("file-lines") { - config.set().file_lines(file_lines.parse()?); + config + .set() + .file_lines(file_lines.parse().map_err(err_msg)?); for f in config.file_lines().files() { match *f { FileName::Custom(ref f) if f == "stdin" => {} @@ -273,7 +278,7 @@ fn format( // that were used during formatting as TOML. if let Some(path) = minimal_config_path { let mut file = File::create(path)?; - let toml = config.used_options().to_toml()?; + let toml = config.used_options().to_toml().map_err(err_msg)?; file.write_all(toml.as_bytes())?; } |
