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();
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元