Chvalov
@Chvalov

Не работает try catch в PHP, как быть?

Постоянно ловлю вот такую вот ошибку:
[2017-10-21 12:56:48] local.ERROR: Screen\Exceptions\PhantomJsException: Unable to load the address! in /var/www/testsite.loc/vendor/microweber/screen/src/Capture.php:259
Stack trace:
#0 /var/www/testsite.loc/app/Console/Commands/SiteScreener.php(73): Screen\Capture->save('/var/www/testsite...')
#1 [internal function]: App\Console\Commands\SiteScreener->handle()
#2 /var/www/testsite.loc/vendor/laravel/framework/src/Illuminate/Container/Container.php(507): call_user_func_array(Array, Array)
#3 /var/www/testsite.loc/vendor/laravel/framework/src/Illuminate/Console/Command.php(169): Illuminate\Container\Container->call(Array)
#4 /var/www/testsite.loc/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /var/www/testsite.loc/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /var/www/testsite.loc/vendor/symfony/console/Application.php(794): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /var/www/testsite.loc/vendor/symfony/console/Application.php(186): Symfony\Component\Console\Application->doRunCommand(Object(App\Console\Commands\SiteScreener), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /var/www/testsite.loc/vendor/symfony/console/Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /var/www/testsite.loc/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/www/testsite.loc/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 {main}
[Screen\Exceptions\PhantomJsException]  
  Unable to load the address!


try {


                        $screenCapture = new Capture( 'http://' . $web -> web_address );

                        $screenCapture->setUserAgentString('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (K$

                        $fileLocation =  public_path( 'websites/' .$web -> web_address . '.' . $screenCapture->getImageType()->ge$

                        $screenCapture->save($fileLocation);

                    } catch (Exception $e) {

                        echo  "Ошибка: " . $e->getMessage(), "\n";

                    }


Вылетает на этом участке https://github.com/microweber/screen/blob/master/s...
// Run the command and ensure it executes successfully
        $returnCode = null;
        $output = [];
        exec(sprintf("%s 2>&1", escapeshellcmd($command)), $output, $returnCode);

        if ($returnCode !== 0) {
            throw new PhantomJsException($output); // ТУТ ВЫЛЕТАЕТ !!!!!
        }

        return file_exists($this->imageLocation);
  • Вопрос задан
  • 684 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы