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

@@ -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];