File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed
rustfmt-bin/src/git-rustfmt
rustfmt-lib/src/formatting Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -63,14 +63,23 @@ fn fmt_files(files: &[&str]) -> i32 {
63
63
64
64
let mut out = stdout ( ) ;
65
65
for file in files {
66
- let report = format ( Input :: File ( PathBuf :: from ( file) ) , & config, setting) . unwrap ( ) ;
67
- if report. has_warnings ( ) {
66
+ let report = match format ( Input :: File ( PathBuf :: from ( file) ) , & config, setting) {
67
+ Ok ( report) => report,
68
+ Err ( e) => {
69
+ eprintln ! ( "{}" , e) ;
70
+ return 1 ;
71
+ }
72
+ } ;
73
+ if report. has_errors ( ) {
68
74
eprintln ! ( "{}" , FormatReportFormatterBuilder :: new( & report) . build( ) ) ;
69
75
}
70
- emit_format_report ( report, & mut out, EmitterConfig :: default ( ) ) . unwrap ( ) ;
76
+ if let Err ( e) = emit_format_report ( report, & mut out, EmitterConfig :: default ( ) ) {
77
+ eprintln ! ( "{}" , e) ;
78
+ return 1 ;
79
+ }
71
80
}
72
81
73
- todo ! ( "Fix error handling" )
82
+ 0
74
83
}
75
84
76
85
struct NullOptions ;
Original file line number Diff line number Diff line change @@ -168,11 +168,6 @@ impl FormatReport {
168
168
. map ( |( _, format_result) | format_result. errors_excluding_macro ( ) . count ( ) )
169
169
. sum ( )
170
170
}
171
-
172
- /// Whether any warnings or errors are present in the report.
173
- pub fn has_warnings ( & self ) -> bool {
174
- self . has_errors ( )
175
- }
176
171
}
177
172
178
173
impl NonFormattedRange {
You can’t perform that action at this time.
0 commit comments