diff --git a/connection.php b/connection.php index 5d614c19..8b010141 100644 --- a/connection.php +++ b/connection.php @@ -28,7 +28,35 @@ class IncompatibleAPIException extends Exception { } * @package phpcassa * @subpackage connection */ -class MaxRetriesException extends Exception { } +class MaxRetriesException extends Exception { + public $cassandra_exception; + public function __construct($e,$ce = false) { + parent::__construct($e); + $this->cassandra_exception = $ce; + } + public function getCassandraMessage() { + switch (get_class($this->cassandra_exception)) { + case 'cassandra_NotFoundException': + return "A specific column was requested that does not exist."; + case 'cassandra_InvalidRequestException': + return "Invalid request could mean keyspace or column family does not exist, required parameters are missing, or a parameter is malformed. why contains an associated error message."; + case 'cassandra_UnavailableException': + return "Not all the replicas required could be created and/or read."; + case 'cassandra_TimedOutException': + return "The node responsible for the write or read did not respond during the rpc interval specified in your configuration (default 10s). This can happen if the request is too large, the node is oversaturated with requests, or the node is down but the failure detector has not yet realized it (usually this takes < 30s)."; + case 'cassandra_TApplicationException': + return "Internal server error or invalid Thrift method (possible if you are using an older version of a Thrift client with a newer build of the Cassandra server)."; + case 'cassandra_AuthenticationException': + return "Invalid authentication request (user does not exist or credentials invalid)"; + case 'cassandra_AuthorizationException': + return "Invalid authorization request (user does not have access to keyspace)"; + case 'cassandra_SchemaDisagreementException': + return "Schemas are not in agreement across all nodes"; + default: + return 'Unknown cassandra Exception:'.get_class($this->cassandra_exception); + } + } +} /** * @package phpcassa @@ -374,7 +402,7 @@ public function call() { } } throw new MaxRetriesException("An attempt to execute $f failed $tries times.". - " The last error was " . get_class($last_err) . ":" . $last_err->getMessage()); + " The last error was " . get_class($last_err) . ":" . $last_err->getMessage(), $last_err); } private function handle_conn_failure($conn, $f, $exc, $retry_count) {