1<?php 2 3/* 4 * This file is part of the Predis package. 5 * 6 * (c) Daniele Alessandri <suppakilla@gmail.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12namespace Predis\Response; 13 14/** 15 * Represents an error returned by Redis (-ERR responses) during the execution 16 * of a command on the server. 17 * 18 * @author Daniele Alessandri <suppakilla@gmail.com> 19 */ 20class Error implements ErrorInterface 21{ 22 private $message; 23 24 /** 25 * @param string $message Error message returned by Redis 26 */ 27 public function __construct($message) 28 { 29 $this->message = $message; 30 } 31 32 /** 33 * {@inheritdoc} 34 */ 35 public function getMessage() 36 { 37 return $this->message; 38 } 39 40 /** 41 * {@inheritdoc} 42 */ 43 public function getErrorType() 44 { 45 list($errorType) = explode(' ', $this->getMessage(), 2); 46 47 return $errorType; 48 } 49 50 /** 51 * Converts the object to its string representation. 52 * 53 * @return string 54 */ 55 public function __toString() 56 { 57 return $this->getMessage(); 58 } 59} 60