Index: lib/src/formatter_options.dart |
diff --git a/lib/src/formatter_options.dart b/lib/src/formatter_options.dart |
index 248941fb9ae088a2e19af01d14687217e6a2aa06..6195d189ad7f294afbe8b1d8ff7894e965cf6861 100644 |
--- a/lib/src/formatter_options.dart |
+++ b/lib/src/formatter_options.dart |
@@ -116,8 +116,13 @@ class _PrintJsonReporter extends OutputReporter { |
class _OverwriteReporter extends _PrintReporter { |
void afterFile(File file, String label, SourceCode output, {bool changed}) { |
if (changed) { |
- file.writeAsStringSync(output.text); |
- print("Formatted $label"); |
+ try { |
+ file.writeAsStringSync(output.text); |
+ print("Formatted $label"); |
+ } on FileSystemException catch (err) { |
+ stderr.writeln("Could not overwrite $label: " |
+ "${err.osError.message} (error code ${err.osError.errorCode})"); |
+ } |
} else { |
print("Unchanged $label"); |
} |