file_errors 1.1.0 file_errors: ^1.1.0 copied to clipboard
Cross-platform extensions that help determine the cause of a caught FileSystemException.
import 'dart:io';
import 'package:file_errors/file_errors.dart';
void main() {
try {
print(File('filename.txt').readAsStringSync());
} on FileSystemException catch (exc) {
if (exc.isNoSuchFileOrDirectory) {
print('File does not exist!');
} else {
print('Unknown error: $exc');
}
}
}