-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from clue-labs/unexpected
Emit "error" event for unexpected response messages
- Loading branch information
Showing
4 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Clue\React\Ami\Protocol; | ||
|
||
use UnexpectedValueException; | ||
|
||
class UnexpectedMessageException extends UnexpectedValueException | ||
{ | ||
private $response; | ||
|
||
public function __construct(Response $response) | ||
{ | ||
parent::__construct('Unexpected message with action ID "' . $response->getActionId() . '" received'); | ||
$this->response = $response; | ||
} | ||
|
||
public function getResponse() | ||
{ | ||
return $this->response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
use Clue\React\Ami\Protocol\Response; | ||
use Clue\React\Ami\Protocol\UnexpectedMessageException; | ||
|
||
class UnexpectedMessageExceptionTest extends TestCase | ||
{ | ||
public function testGetResponse() | ||
{ | ||
$response = new Response(array('ActionID' => 1)); | ||
|
||
$exception = new UnexpectedMessageException($response); | ||
|
||
$this->assertSame($response, $exception->getResponse()); | ||
} | ||
} |