sql = $sql; // TODO: add $profiler->exception($this); } /** * @return string The SQL passed to the constructor */ final public function getSql() { return $this->sql; } /** * @return string string represenation of exception with SQL command */ public function __toString() { return parent::__toString() . ($this->sql ? "\nSQL: " . $this->sql : ''); } /********************* interface Nette\IDebuggable ****************d*g**/ /** * Returns custom panels. * @return array */ public function getPanels() { $panels = array(); if ($this->sql !== NULL) { $panels['SQL'] = array( 'expanded' => TRUE, 'content' => dibi::dump($this->sql, TRUE), ); } return $panels; } /********************* error catching ****************d*g**/ /** * Starts catching potential errors/warnings * @return void */ public static function tryError() { set_error_handler(array(__CLASS__, '_errorHandler'), E_ALL); self::$errorMsg = NULL; } /** * Returns catched error/warning message. * @param string catched message * @return bool */ public static function catchError(& $message) { restore_error_handler(); $message = self::$errorMsg; self::$errorMsg = NULL; return $message !== NULL; } /** * Internal error handler. Do not call directly. * @internal */ public static function _errorHandler($code, $message) { restore_error_handler(); if (ini_get('html_errors')) { $message = strip_tags($message); $message = html_entity_decode($message); } self::$errorMsg = $message; } }