thephpleague / flysystem

Abstraction for local and remote filesystems
https://flysystem.thephpleague.com
MIT License
13.35k stars 826 forks source link

Cannot catch exceptions #568

Closed craftpip closed 8 years ago

craftpip commented 8 years ago

Hello, i generated some obvious errors, for example: $filesystem->has('nonExistentDir'); It seems Try catch isn't working for this. The error bypasses try catch.

Thank you.

frankdejonge commented 8 years ago

@craftpip what errors are you getting?

craftpip commented 8 years ago

hello I'm sorry, the error is not at $filesystem->has('nonExistentDir');

But I'm not able to catch the errors, when i try to login with incorrect information. or when it reaches timeout.

frankdejonge commented 8 years ago

@craftpip what do you mean with login?

craftpip commented 8 years ago

When using the FTP,FTPS,SFTP adapters. (or others) i try to login to servers with incorrect credentials.

code:

try {
    // the $ftpadapter and $flysystem is initiated here.
    // later i do try to listContents of the ftp server. (The login information i provided were invalid)
    $a = $filesystem->listContents(); // this gives the error.
} catch ( \Exception $e){
    // But the error is not caught here.
    echo $e->getMessage();
}

Also, I'm using FuelPHP framework.

craftpip commented 8 years ago

For example: Fuel\Core\PhpErrorException [ Warning ]: ftp_systype(): Sorry, cleartext sessions are not accepted on this server.

cannot be handled.

frankdejonge commented 8 years ago

@craftpip I'm not sure what we could do from flysystem's side to improve this. It seems like you've got misconfiguration, so you need to fix the credentials rather than catch the error at runtime.

craftpip commented 8 years ago

I'm despirate to get Flysystem working with FuelPHP, i need to handle FTP exceptions because I'm building a FTP connection test GUI, which needs to show errors. However the exceptions are caught in set_error_handler but doesn't really help.

Anyways thanks for your support Frank. :)

frankdejonge commented 8 years ago

@craftpip I don't think Flysystem is the tool to do that. It is meant to be used when you have valid credentials.

craftpip commented 8 years ago

@frankdejonge Thanks again man. :)