mapDirPickerError method

  1. @protected
FileSaverException mapDirPickerError(
  1. Object e,
  2. String action
)

Converts an error from dir_picker into a FileSaverException: an ArgumentError (a location the platform can't use) into an InvalidInputException, and anything else into a NativePlatformException that keeps the DirPickerException.code.

Implementation

@protected
FileSaverException mapDirPickerError(Object e, String action) => switch (e) {
  FileSaverException() => e,
  DirPickerException(:final code, :final message) => NativePlatformException(
    '$action: ${message ?? code}',
    code,
  ),
  ArgumentError(:final message) => InvalidInputException('$action: $message'),
  _ => NativePlatformException('$action: $e'),
};