Explode Response to Frames

This commit is contained in:
2021-01-30 17:14:19 +03:00
parent fc6b67cc92
commit f74b82a400
24 changed files with 367 additions and 148 deletions

View File

@ -4,8 +4,10 @@ declare(strict_types=1);
namespace Nsq\Exception;
use RuntimeException;
final class AuthenticationRequired extends RuntimeException implements NsqException
final class AuthenticationRequired extends NsqException
{
public function __construct()
{
parent::__construct('NSQ requires authorization, set ClientConfig::$authSecret before connecting');
}
}

View File

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace Nsq\Exception;
use Nsq\Protocol\Response;
final class BadResponse extends NsqException
{
public function __construct(Response $response)
{
parent::__construct($response->msg);
}
}

View File

@ -4,10 +4,9 @@ declare(strict_types=1);
namespace Nsq\Exception;
use RuntimeException;
use Throwable;
final class ConnectionFail extends RuntimeException implements NsqException
final class ConnectionFail extends NsqException
{
/**
* @codeCoverageIgnore

View File

@ -4,10 +4,9 @@ declare(strict_types=1);
namespace Nsq\Exception;
use Nsq\Message;
use RuntimeException;
use Nsq\Protocol\Message;
final class MessageAlreadyFinished extends RuntimeException implements NsqException
final class MessageAlreadyFinished extends NsqException
{
public static function finish(Message $message): self
{

View File

@ -4,8 +4,12 @@ declare(strict_types=1);
namespace Nsq\Exception;
use RuntimeException;
use Nsq\Protocol\Error;
final class NsqError extends RuntimeException implements NsqException
final class NsqError extends NsqException
{
public function __construct(Error $error)
{
parent::__construct($error->rawData);
}
}

View File

@ -4,8 +4,8 @@ declare(strict_types=1);
namespace Nsq\Exception;
use Throwable;
use RuntimeException;
interface NsqException extends Throwable
class NsqException extends RuntimeException
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Nsq\Exception;
final class NullReceived extends NsqException
{
}

View File

@ -1,18 +0,0 @@
<?php
declare(strict_types=1);
namespace Nsq\Exception;
use RuntimeException;
final class UnexpectedResponse extends RuntimeException implements NsqException
{
/**
* @codeCoverageIgnore
*/
public static function null(): self
{
return new self('Response was expected, but null received.');
}
}