file_errors

Last updated:

0 purchases

file_errors Image
file_errors Images
Add to Cart

Description:

file errors

file_errors #
Cross-platform extensions that help determine the cause of
a caught FileSystemException:

FileSystemException.isNoSuchFileOrDirectory
FileSystemException.isDirectoryNotEmpty

isNoSuchFileOrDirectory #
Occurs when:

Trying to read a non-existent file in an existing directory
Trying to read or write a file in a non-existent directory
Trying to non-recursively create a file in a non-existent directory
Trying to list a non-existent directory

try {

print(File('maybe.txt').readAsStringSync());

} on FileSystemException catch (exc) {

// using property extension added by the library
if (exc.isNoSuchFileOrDirectory) {
print('It does not exist!');
}
else {
print('Unknown error: $exc');
}
}
copied to clipboard
isDirectoryNotEmpty #
Occurs when you try to non-recursively delete a directory but it contains files.
try {

Directory('/path/to/useless').deleteSync();

} on FileSystemException catch (exc) {

// using property extension added by the library
if (exc.isDirectoryNotEmpty) {
print('It is not empty!');
}
else {
print('Unknown error: $exc');
}
}
copied to clipboard
Compatibility #
The extensions were unit-tested on Linux, Windows and MacOS.
Mobile systems such as Android and iOS have the same kernels
as their desktop relatives. So their error codes are the same.
Under the hood #
This library interprets the OSError.errorCode values depending on the
current platform. It's two different error codes for isNoSuchFileOrDirectory
and three different error codes for isDirectoryNotEmpty.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.