P
P
ptand2020-07-03 14:51:19
Yii
ptand, 2020-07-03 14:51:19

How to catch 503 error in php, yii2?

On yii2, when sending a curl request with a non-working proxy, the server gives a 503 error, what kind of exception to catch it in catch? If you write your own, then hint where to look, or better, skinte the code.
curl options:
[

[42] => 1
[81] =>
[64] =>
[19913] => 1
[2] => 1
[10004] => 35.45.45.45:45
[10006] => rfgth:fgn
[101] => 0
[10002] => https://google.com/
]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2020-07-03
@ptand

try {
    //Код с ошибкой
} catch (Exception $e) {
    if ($e->getCode() === 503) {
        ///Ваша обработка
    }
    Yii::$app->errorHandler->logException($e); //Записываем ошибку в лог
}

V
Vladislav, 2020-07-03
@cr1gger

$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($http == 503) {
        die;
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question