for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace NotificationChannels\MobilyWs\Exceptions;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Exception\RequestException;
class CouldNotSendMobilyWsNotification extends \Exception
{
/**
* Thrown when mobily.ws return a response body other than '1'.
*
* @param $code
* @param $message
* @return static
*/
public static function mobilyWsRespondedWithAnError($code, $message)
return new static(
sprintf("Mobily.ws responded with error number %s and message:\n%s",
$code,
$message
));
}
* Thrown when GuzzleHttp throw a request exception.
* @param RequestException $exception
public static function couldNotSendRequestToMobilyWs(RequestException $exception)
'Request to mobily.ws failed',
$exception->getCode(),
$exception
);
* Thrown when any other errors received.
* @param Response $response
public static function someErrorWhenSendingSms(Response $response)
$code = $response->getStatusCode();
$message = $response->getBody()->getContents();
sprintf('Could not send sms notification to mobily.ws. Status code %s and message: %s', $code, $message)
* Thrown when any other errors occur.
public static function withErrorMessage($message)
return new static($message);