2016-10-24 19:01:32 +02:00
|
|
|
<?php
|
|
|
|
|
2016-11-23 16:02:12 -06:00
|
|
|
/*
|
2017-11-22 00:37:04 -08:00
|
|
|
* Copyright (C) 2013 Mailgun
|
2016-11-23 16:02:12 -06:00
|
|
|
*
|
|
|
|
* This software may be modified and distributed under the terms
|
2016-12-06 12:12:52 -06:00
|
|
|
* of the MIT license. See the LICENSE file for details.
|
2016-11-23 16:02:12 -06:00
|
|
|
*/
|
|
|
|
|
2016-10-24 19:01:32 +02:00
|
|
|
namespace Mailgun\Exception;
|
|
|
|
|
|
|
|
use Mailgun\Exception;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
|
|
|
*/
|
2017-03-26 10:16:36 +02:00
|
|
|
final class HttpServerException extends \RuntimeException implements Exception
|
2016-10-24 19:01:32 +02:00
|
|
|
{
|
|
|
|
public static function serverError($httpStatus = 500)
|
|
|
|
{
|
2018-01-29 16:18:02 +00:00
|
|
|
return new self('An unexpected error occurred at Mailgun\'s servers. Try again later and contact support if the error still exists.', $httpStatus);
|
2016-10-24 19:01:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function networkError(\Exception $previous)
|
|
|
|
{
|
2017-06-24 00:46:48 -05:00
|
|
|
return new self('Mailgun\'s servers are currently unreachable.', 0, $previous);
|
2016-10-24 19:01:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function unknownHttpResponseCode($code)
|
|
|
|
{
|
|
|
|
return new self(sprintf('Unknown HTTP response code ("%d") received from the API server', $code));
|
|
|
|
}
|
|
|
|
}
|