Carpe-Hora / SmsSender

[DEPRECATED] The almost missing SMS sending PHP library.
MIT License
54 stars 19 forks source link

2.add error handling in http adapter #24

Open Avtonom opened 7 years ago

Avtonom commented 7 years ago
$sender = new \SmsSender\SmsSender();
try {
    $sendResult = $sender->send('0642424242', 'It\'s the answer.', 'Kévin');
} catch(\SmsSender\Exception\WrappedException $e){
    if($e->getWrappedException() && $e->getWrappedException() instanceof \SmsSender\Exception\AdapterException){
        $smsException = new \Exception($e->getWrappedException()->getMessage(), $e->getWrappedException()->getCode(), $e);
        if($e->getWrappedException()->getData()){
            var_dump($e->getWrappedException()->getData()); // request data
        }

    }
    throw $smsException;
}