2016-08-25 4 views
1

Я хочу загрузить файл с помощью FTP с Laravel 5.1, и я хочу проверить, существует ли файл в удаленной папке. Я включил use Illuminate\Contracts\Filesystem\Filesystem, но не может его поймать исключение со следующим сообщением об ошибке: [Осветить \ Контракты \ Filesystem \ FileNotFoundException]
p25082016.csv

Мой код выглядит следующим образом:Laravel 5.1 Catching FTP File not found exception

 

    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