onError property

void Function(FileSystemException error)? onError
final

Receives the failures that the walk recovers from.

Called with the FileSystemException of a directory that could not be listed (for example a PathAccessException for a directory without read permission, or a PathNotFoundException for one deleted during the scan), and of a link to a directory whose target could not be resolved. The directory or link is still reported as an entry and the walk continues with the next directory. scan keeps the entities that were listed before a failure; scanSync cannot, because the synchronous listing fails as a whole. For a directory that was listed again, or a link that was resolved again, through its Windows extended-length path (see DirectoryScanner), the error is the one of that second attempt, so its path starts with \\?\.

null (the default) ignores these failures. An exception thrown by the callback aborts the scan and propagates to the caller.

Implementation

final void Function(FileSystemException error)? onError;