Skip to content

Commit

Permalink
Fixing compatibity issues with php 5.5, 5.6 and hhvm
Browse files Browse the repository at this point in the history
  • Loading branch information
mariano committed May 10, 2016
1 parent 4c1e33b commit 23763c5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,11 @@
All Notable changes will be documented in this file. This project adheres to
[Semantic Versioning](http://semver.org/).

## [2.0.2] - 2016-05-10

### Fixed
- Compatibility issues with PHP 5.5, 5.6 and hhvm

## [2.0.1] - 2016-05-10

### Changed
Expand Down Expand Up @@ -148,6 +153,7 @@ parameters were specified, an `InvalidCommandArgumentException` was thrown.
- Added support for Predis connections, and allowing adding new connection
methods via `ConnectionInterface`.

[2.0.2]: https://github.com/mariano/disque-php/releases/tag/2.0.2
[2.0.1]: https://github.com/mariano/disque-php/releases/tag/2.0.1
[2.0-alpha]: https://github.com/mariano/disque-php/releases/tag/2.0-alpha
[1.3.0]: https://github.com/mariano/disque-php/releases/tag/1.3.0
Expand Down
26 changes: 19 additions & 7 deletions src/Connection/Response/ErrorResponse.php
Expand Up @@ -3,9 +3,6 @@

class ErrorResponse extends BaseResponse
{
const ERRORS = [
'PAUSED' => QueuePausedResponseException::class
];
/**
* Parse response
*
Expand All @@ -14,11 +11,26 @@ class ErrorResponse extends BaseResponse
public function parse()
{
$error = (string) $this->data;
$exceptionClass = $this->getExceptionClass($error);
return new $exceptionClass($error);
}

/**
* Creates ResponseException based off error
*
* @param string $error Error
* @return string Class Name
*/
private function getExceptionClass($error)
{
$errors = [
'PAUSED' => QueuePausedResponseException::class
];
$exceptionClass = ResponseException::class;
list($errorCode) = explode(" ", $error);
if (!empty($errorCode) && isset(static::ERRORS[$errorCode])) {
$exceptionClass = static::ERRORS[$errorCode];
throw new $exceptionClass($error);
if (!empty($errorCode) && isset($errors[$errorCode])) {
$exceptionClass = $errors[$errorCode];
}
return new ResponseException($error);
return $exceptionClass;
}
}

0 comments on commit 23763c5

Please sign in to comment.