2016-08-25 19 views
1

Laravel 5.1でFTPを使用してファイルをダウンロードしたいのですが、そのファイルがリモートフォルダに存在するかどうか確認したいと思います。私はuse Illuminate\Contracts\Filesystem\Filesystem含まれるが、それは次のエラーで例外をキャッチするために失敗します。 [\契約を照らす\ファイルシステム\にFileNotFoundException]
私のコードは次のようになり
p25082016.csv:Laravel 5.1 FTPファイルが見つからない例外

 

    private function getFile() 
    { 
     try { 
     // CONNECT TO FTP AND GET THE FILE 
     } catch (FileNotFoundException $exception) { 
     die('File: '.$filename.' error'); 
     } 
     return 'File: '.$filename.' OK'; 

    } 

任意のヘルプ?

+1

あなたが同様に例外を輸入してい? 'Illuminate \ Contracts \ Filesystem \ FileNotFoundException'を使用しますか? –

+0

こんにちは@Björn、はい、あなたが言及したその例外をインポートしました –

答えて

1

All exceptions are handled by the App\Exceptions\Handler class
....
The render method is responsible for converting a given exception into an HTTP response that should be sent back to the browser. By default, the exception is passed to the base class which generates a response for you. However, you are free to check the exception type or return your own custom response

https://laravel.com/docs/5.5/errors#the-exception-handler

関連する問題