dtgr3392 2016-09-24 19:43
浏览 67

LaravelCollective SSH尝试捕获异常失败

I need code for exceptions on connections. I use SSH of LaravelColletive on Laravel 5.3

When the exception belongs to ErrorException, such as that you can not connect to a port, if I work.

try {
   SSH::into('old')->get($full_old_file,$temp_file);
} catch (\ErrorException $e) {
   echo $e->getMessage();
}

if error it's incorrect port, show error and app continues.

Cannot connect to kvm401.hostname.com:22. Error 111. Connection refused

But if problem it's for example a use wrong ssh key, exception it's catched by RuntimeException and my try .. catch block not work, and app stop run.

[RuntimeException]                   
  Unable to connect to remote server. 

if possible try catch any type of exception?

  • 写回答

1条回答 默认 最新

  • douzhuo2722 2017-09-11 12:37
    关注

    The below should catch all exceptions

    try {
        SSH::into('old')->get($full_old_file,$temp_file);
    } catch (\Exception $e) {
        echo $e->getMessage();
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统