更新时间:2022-02-13 16:42:12
它看起来像你只能捕捉GuzzleHttp \Ring\Exception\ConnectException异常
it looks like you can just catch the GuzzleHttp\Ring\Exception\ConnectException exception
像这样:
use GuzzleHttp\Ring\Exception\ConnectException;
try {
// the code which throws the error
} catch( ConnectException $ex ) {
switch ( $ex->getMessage() ) {
case '7': // to be verified
// handle your exception in the way you want,
// maybe with a graceful fallback
break;
}
}
它会出现guzzle的ConnectException 扩展 一些 类,最终扩展了php的异常,以便您可以安全地使用getCode()方法,允许您捕获一个标识符,您可以根据自己的需要做出相应的反应。
it appears guzzle's ConnectException extends some classes and ultimately extends php's Exception so you can safely use the getCode() method, allowing you to catch an identifier on which you can react accordingly to your needs.