ServerException.php 968 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /*
  3. * This file is part of the Predis package.
  4. *
  5. * (c) Daniele Alessandri <suppakilla@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Predis\Response;
  11. use Predis\PredisException;
  12. /**
  13. * Exception class that identifies server-side Redis errors.
  14. *
  15. * @author Daniele Alessandri <suppakilla@gmail.com>
  16. */
  17. class ServerException extends PredisException implements ResponseErrorInterface
  18. {
  19. /**
  20. * Gets the type of the error returned by Redis.
  21. *
  22. * @return string
  23. */
  24. public function getErrorType()
  25. {
  26. list($errorType, ) = explode(' ', $this->getMessage(), 2);
  27. return $errorType;
  28. }
  29. /**
  30. * Converts the exception to an instance of ResponseError.
  31. *
  32. * @return ResponseError
  33. */
  34. public function toResponseError()
  35. {
  36. return new ResponseError($this->getMessage());
  37. }
  38. }