tools icon indicating copy to clipboard operation
tools copied to clipboard

Local and memory implementation throw different exceptions

Open shilangyu opened this issue 1 year ago • 0 comments

Trying to copy a file that does not exist throws different exceptions depending on the underlying implementation.

Assuming file aaa does not exist:

import 'package:file/file.dart';
import 'package:file/local.dart';

void main() async {
    await LocalFileSystem().file('aaa').copy('else');
}

Will throw PathNotFoundException, but

import 'package:file/file.dart';
import 'package:file/memory.dart';

void main() async {
    await MemoryFileSystem().file('aaa').copy('else');
}

will throw FileSystemException.

Technically FileSystemException <: FileSystemException so handling just FileSystemException should be enough. But this is still a deviation and perhaps should be handled.

shilangyu avatar May 15 '23 16:05 shilangyu