/** * Returns a detailed error message. * * The error message contains: * 1. Error Number (only if greater than zero) * 2. Error Message * 3. File Name * 4. Line Number of the file * 5. Executed SQL Query (optional) * * @return string All error details as string */ public function __toString() { $error = parent::__toString(); if (empty($this->query) == false) { $query = Strings::replaceLineBreaks($this->query, "\t"); $error .= "\r\nQuery: {$query}"; } return $error; }
function __construct($connect_string, $extra = '') { $message = 'Couldnt connect to "' . $connect_string . '"'; if ($extra) { $message .= '. ' . $extra; } parent::__construct($message); }
public function __construct($message = 'An error occured attempting to connect to the database', $code = 0, \Exception $previous = null) { parent::__construct($message, $code, $previous); }
/** * Handle an error message * * @param string $method * @param string $error * @throws DatabaseException */ protected function error(string $method, string $error) { $this->errors[] = $error; if (property_exists($this, "lastQuery") && is_object($this->lastQuery)) { if (property_exists($this->lastQuery, "error")) { $this->lastQuery->error = $error; } } if (!$this->config->silentMode) { throw DatabaseException::queryError($method, $error); } }
function __construct($sql) { parent::__construct('Query "' . $sql . '" timed out.'); }
/** * @param string $message * @param number $code * @param Exception $previous */ function __construct($message = null, $code = 0, Exception $previous = null) { parent::__construct('undefined exception: ' . $message, $code, $previous); }
public function __construct($message, $code = 0, $previous = null) { parent::__construct($message, $code, $previous); }
/** * Traite les erreurs (suivant le param $_CONST['POOL'][$conn]['ERROR']) * @param DB_driver_PDO $connection Peut être null * @param DatabaseException $exception * @throws DatabaseException Si error_type == 'exception' */ public static function handleError($connection, $exception) { // $connection peut être null s'il n'a pas encore été initialisé if (!$connection) { $exception->warn(); } else { if ($connection->debug_type) { self::debug($connection, 0, $exception); } switch ($connection->error_type) { case 'exception': throw $exception; break; case 'silent': $exception->log(); break; case 'warning': default: $exception->warn(); } } }
public function __construct($message = null, $code = null) { parent::__construct($message); $this->code = $code; }
function __construct($sql, $error = 'Unknown') { parent::__construct('Error executing "' . substr($sql, 0, 75) . '", Error: ' . $error); $this->error = $error; }
public static function singleField($field, $message) { $errors = new DatabaseException(); $errors->addError($field, $message); return $errors; }
function __construct($message = 'Error fetching data from Database') { parent::__construct($message); }
public function __construct($message = 'The specified database configuration is invalid', $code = 0, \Exception $previous = null) { parent::__construct($message, $code, $previous); }
public function __construct($message, $code = 0, Exception $previous = null) { // some code // make sure everything is assigned properly parent::__construct($message, $code, $previous); }
public function __construct($message = 'An error occured executing a database query', $code = 0, \Exception $previous = null) { parent::__construct($message, $code, $previous); }
function __construct($query, $pglink) { $this->_query = $query; $this->_errmsg = pg_errormessage($pglink); parent::__construct("Database-Error {$this->_errmsg} on query {$query}"); }
/** * Commits a transaction * * @throws DatabaseException */ public function commit() { try { $commit = $this->pdo->commit(); if (!$commit) { throw DatabaseException::pdoError("Failed to commit transaction"); } } catch (\PDOException $e) { throw DatabaseException::pdoError($e->getMessage()); } }
/** * The render function will take a DatabaseException and output a * HTML page. * * @param DatabaseException $e * The Exception object * @return string * An HTML string */ public static function render($e) { $trace = NULL; $odd = true; foreach ($e->getTrace() as $t) { $trace .= sprintf('<li%s><code>[%s:%d] <strong>%s%s%s();</strong></code></li>', $odd == true ? ' class="odd"' : NULL, $t['file'], $t['line'], isset($t['class']) ? $t['class'] : NULL, isset($t['type']) ? $t['type'] : NULL, $t['function']); $odd = !$odd; } $queries = NULL; $odd = true; if (is_object(Symphony::Database())) { $debug = Symphony::Database()->debug(); if (count($debug['query']) > 0) { foreach ($debug['query'] as $query) { $queries .= sprintf('<li%s><code>%s;</code> <small>[%01.4f]</small></li>', $odd == true ? ' class="odd"' : NULL, htmlspecialchars($query['query']), isset($query['time']) ? $query['time'] : NULL); $odd = !$odd; } } } return sprintf(file_get_contents(TEMPLATE . '/fatalerror.tpl'), $e->getDatabaseErrorMessage(), $e->getQuery(), $trace, $queries); }
/** * @param string $message * @param number $code * @param Exception $previous */ function __construct($message = null, $code = 0, Exception $previous = null) { parent::__construct('unknown database exception: ' . $message, $code, $previous); }
/** * Swallow a schema not upgraded exception, otherwise rethrow it * * @param \DatabaseException $exception The exception to handle * @param string $default The value to return if the table doesn't exist yet * * @return mixed * * @throws \DatabaseException */ protected function handleDbException(\DatabaseException $exception, $default = null) { if (false !== strpos($exception->getMessage(), "users_remember_me_cookies' doesn't exist")) { // schema has not been updated so we swallow this exception return $default; } else { throw $exception; } }
/** * @param string $message = 'Requested dataset was not found!' * @param int $code = 404 * @param \Exception|null $previous = null */ public function __construct($message = 'Requested dataset was not found!', $code = 404, \Exception $previous = null) { parent::__construct($message, $code, $previous); }
public function __construct($message = 'The database is not connected', $code = 0, \Exception $previous = null) { parent::__construct($message, $code, $previous); }
/** * Creates a new fetch statement exception. * @param $function string The function name. */ public function __construct($function) { parent::__construct('fetch', $function); }
/** * Generic request execution method * @param string $request The request string * @return resource The request results or an exception if any error occures */ protected function &request($request) { $timer = TimerTool::getInstance(); $timer->tick('Executing request (' . $this->dbName . ') : ' . $request, 'ms', 0, FALSE); $timer->incrementCount(); // Request execution $result = mysql_unbuffered_query($request, $this->dbLink); if (!$result) { $mysqlErrNo = mysql_errno($this->dbLink); $mysqlErrMsg = mysql_error($this->dbLink); // Mysql connection lost : reconnect and retry query if (!$this->isConnected()) { $logInstance = LogTool::getInstance(); $logInstance->logWarning('Connection lost (Error #' . $mysqlErrNo . ' : ' . $mysqlErrMsg . ') during request execution, will reconnect and retry it : ' . $request); $this->connect(); $logInstance->logWarning('Retrying request (' . $this->dbName . ') : ' . $request); $result = mysql_unbuffered_query($request, $this->dbLink); if (!$result) { throw DatabaseException::getSpecificException('Error while executing query (retry): "' . $request . '" (Error #' . $mysqlErrNo . ' : ' . $mysqlErrMsg . ')', $mysqlErrNo); } } else { throw DatabaseException::getSpecificException('Error while executing following query : "' . $request . '" (Error #' . $mysqlErrNo . ' : ' . $mysqlErrMsg . ')', $mysqlErrNo); } } $timer->tick('Finished executing request', 'ms', 0, TRUE); return $result; }
/** * @param string $statement * @param number $code * @param Exception $previous */ function __construct($statement = null, $code = 0, Exception $previous = null) { parent::__construct('invalid SQL statement: ' . $statement, $code, $previous); }