tryMap method

  1. @override
Failure? tryMap(
  1. Object error, [
  2. StackTrace? stackTrace
])
override

Пытается преобразовать error в Failure, если это ошибка файловой системы.

Определяет тип ошибки через PlatformExceptions и анализирует путь для выбора между FileFailure и StorageFailure.

Возвращает: Failure или null, если ошибка не относится к файловой системе.

Implementation

@override
Failure? tryMap(Object error, [StackTrace? stackTrace]) {
  final details = PlatformExceptions.fileSystemDetails(error);
  if (details == null) return null;

  if (PlatformExceptions.isPathNotFoundException(error)) {
    return _mapPathNotFound(details.path, details.message);
  }
  return _mapFileSystem(details.path, details.message);
}