/** * \brief Write message to stdout and die. * * \param $msg - Message to write * \param $filenm - File name (__FILE__) * \param $lineno - Line number of the caller (__LINE__) * * \return None, prints error, file, and line number, then exits(1) */ function Fatal($msg, $filenm, $lineno) { echo "<hr>FATAL error, File: {$filenm}, Line number: {$lineno}<br>"; echo "{$msg}<hr>"; debugbacktrace(); exit(1); }
/** * \brief Check the postgres result for unexpected errors. * If found, treat them as fatal. * * \param $result command result object * \param $sql SQL command (optional) * \param $filenm File name (__FILE__) * \param $lineno Line number of the caller (__LINE__) * * \return None, prints error, sql and line number, then exits(1) **/ function DBCheckResult($result, $sql, $filenm, $lineno) { global $PG_CONN; if (!$result) { echo "<hr>File: {$filenm}, Line number: {$lineno}<br>"; if (pg_connection_status($PG_CONN) === PGSQL_CONNECTION_OK) { echo pg_last_error($PG_CONN); } else { echo "FATAL: DB connection lost."; } echo "<br> {$sql}"; debugbacktrace(); echo "<hr>"; exit(1); } }
protected function _sendHtml($html) { $this->getResponse()->setHeader('Content-type', 'application/json'); $encodedHtml = Zend_Json::encode($html); if (!$encodedHtml) { $errorMessage = ""; switch (json_last_error()) { case JSON_ERROR_NONE: $errorMessage = ' - No errors'; break; case JSON_ERROR_DEPTH: $errorMessage = ' - Maximum stack depth exceeded'; break; case JSON_ERROR_STATE_MISMATCH: $errorMessage = ' - Underflow or the modes mismatch'; break; case JSON_ERROR_CTRL_CHAR: $errorMessage = ' - Unexpected control character found'; break; case JSON_ERROR_SYNTAX: $errorMessage = ' - Syntax error, malformed JSON'; break; case JSON_ERROR_UTF8: $errorMessage = ' - Malformed UTF-8 characters, possibly incorrectly encoded'; break; default: $errorMessage = ' - Unknown error'; break; } $logger = Zend_Registry::get("logger"); $logger->sendException($errorMessage . "\n\n" . debugbacktrace(false), "json_exception_", false); $html = array("error" => 1, "message" => $this->_("An error occurred while loading. Please try again later.")); $encodedHtml = Zend_Json::encode($html); } if (is_array($html) and !empty($html['error'])) { $this->getResponse()->setHttpResponseCode(400); } $this->getLayout()->setHtml($encodedHtml); }
public function render($name = null) { if (is_null($this->_html)) { $this->renderPartials(); if (!$this->_base_render) { debugbacktrace(); } $name = $this->_base_render->getTemplate(); if ($this->inflectorEnabled() && null !== ($inflector = $this->getInflector())) { $name = $this->_inflector->filter(array('script' => $name)); } $view = $this->_base_render; if (null !== ($path = $this->getViewScriptPath())) { if (method_exists($view, 'addScriptPath')) { $view->addScriptPath($path); } else { $view->setScriptPath($path); } } elseif (null !== ($path = $this->getViewBasePath())) { $view->addBasePath($path, $this->_viewBasePrefix); } $this->_html = $view->render($name); } return $this->_html; }