You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the Storage API is similar to the one from PHP and simply returns false when an error occurred.
This makes it difficult to distinguish whether "false" means "File not found" or "Storage not available".
We should move to using exceptions in such cases and get rid of booleans.
I think it comes down to catching 3rd party exceptions then wrapping them into our exceptions. Perhaps some system for a storage to define what exceptions may be thrown from it, and what they should 'map' to? For example, the DAV storage backend would map Sabre\DAV\Exception\NotFound to OCP\Files\NotFoundException. Then, without any extra try catch blocks in the storages themselves, a wrapper or the filesystem itself would catch such errors, then wrap them in our exceptions.
try {
$storage->doSomething();
} catch (\Exception $e) {
foreach ($storage->getExceptionMap() as $orig => $wrapper) {
if (is_instance($e, $orig)) {
throw new $wrapper(..., $e);
}
}
throw new \OCP\Files\UnknownFailureException(..., $e);
}
Currently the Storage API is similar to the one from PHP and simply returns false when an error occurred.
This makes it difficult to distinguish whether "false" means "File not found" or "Storage not available".
We should move to using exceptions in such cases and get rid of booleans.
@Xenopathic @icewind1991 @schiesbn @DeepDiver1975
The text was updated successfully, but these errors were encountered: