Gaufrette icon indicating copy to clipboard operation
Gaufrette copied to clipboard

[1.0] Use exceptions if error(s) happen(s)

Open akerouanton opened this issue 7 years ago • 1 comments

Currently we return false (or something similar) to notify error(s). It leads to bad DX. However, in some cases native exceptions are used but they're too general. Specific exceptions would be better, we should improve this for v1.0.

Proposal

  • Introduce a generic exception for Adapter (named StorageFailure)
  • Introduce a generic exception for Filesystem (named FilesystemFailure)

The reason for two distinct exceptions goes as is: Filesystem has a compatibility layer that mimics some behaviors based on the minimal subset of functionality offered by Adapter interface.

Also, it would be great to introduce more specific exceptions like FileNotFound.

Todo

  • [ ] Filesystem
  • [x] Adapter (interface) (see #517)
  • [x] AwsS3 (see #517)
  • [x] AzureBlobStorage (see #521)
  • [x] DoctrineDbal (see #521)
  • [x] Flysystem (see #519)
  • [x] Ftp (see #521)
  • [x] GridFS (see #521)
  • [x] Local (see #521)
  • [ ] OpenCloud (see #533)
  • [x] PhpseclibSftp (see #521)
  • [x] Zip (see #521)

akerouanton avatar Jun 02 '17 13:06 akerouanton

We need to remove support of php v5.6 if we want to properly handle errors for Local adapter. Also OpenCloud adapter shouldn't be fixed for now: it's based on an outdated SDK.

akerouanton avatar Aug 08 '17 02:08 akerouanton