Add UnroutableSmsMessageException

This commit is contained in:
Javier Hernández Gil 2014-04-08 01:27:44 +02:00
parent 7de3c7aea9
commit 661df5ac9e
3 changed files with 21 additions and 2 deletions

View File

@ -36,7 +36,7 @@ class SmsManager
* @param string $message
* @param null|string $fromName
* @param int $status_report_req
* @return mixed
* @return SmsSendResponse
*/
public function sendText($number,$message,$fromName=null,$status_report_req=0) {
$fromName = $fromName!==null ? $fromName : $this->defaultFromName;

View File

@ -0,0 +1,11 @@
<?php
namespace Jhg\NexmoBundle\NexmoClient\Exceptions;
/**
* Class UnroutableSmsMessageException
* @package Jhg\NexmoBundle\NexmoClient\Exceptions
* @author Javi Hernández
*/
class UnroutableSmsMessageException extends \Exception {
}

View File

@ -1,6 +1,8 @@
<?php
namespace Jhg\NexmoBundle\NexmoClient;
use Jhg\NexmoBundle\NexmoClient\Exceptions\UnroutableSmsMessageException;
class NexmoClient {
/**
@ -99,7 +101,13 @@ class NexmoClient {
$response = $this->jsonRequest('/sms/json',$params);
if((int)$response['messages'][0]['status']!=0) {
throw new \Exception($response['messages'][0]['error-text']);
switch((int)$response['messages'][0]['status']) {
case 6:
throw new UnroutableSmsMessageException();
default:
throw new \Exception($response['messages'][0]['error-text']);
}
}
return $response['messages'][0];