/** * Format a JError object as a JSON string */ public function raiseError($error) { $data = array(); $data[] = JError::translateErrorLevel($error->get('level')) . ' ' . $error->get('code') . ': '; if ($error->get('message')) { $data[] = $error->get('message'); } if ($error->get('code') >= 500) { if ($error->get('line')) { $data[] = ' IN LINE ' . $error->get('line'); } if ($error->get('function')) { $text = ' IN '; if ($error->get('class')) { $text = $error->get('class') . '::'; } $text = $error->get('function'); $data[] = $text; } if ($error->get('file')) { $data[] = 'IN FILE ' . $error->get('file'); } } header('Content-Type: text/json'); header('Content-Encoding: UTF-8'); $output = array('result' => '', 'error' => true, 'code' => $error->get('code'), 'text' => $data); exit(json_encode($output)); }
/** * Format a JError object as a JSON string */ public static function raiseError($error) { $data = array(); $data[] = JError::translateErrorLevel($error->get('level')) . ' ' . $error->get('code') . ': '; if ($error->get('message')) { $data[] = $error->get('message'); } $output = array('result' => '', 'error' => true, 'code' => $error->get('code'), 'text' => $data); header('Content-Type: text/json'); header('Content-Encoding: UTF-8'); exit(json_encode($output)); }
/** * Die error handler * - Echos the error message to output and then dies * * @param object &$error Exception object to handle * @param array $options Handler options * * @return object The exception object * * @deprecated 12.1 * @see raise() * @since 11.1 */ public static function handleDie(&$error, $options) { // Deprecation warning. JLog::add('JError::handleDie() is deprecated.', JLog::WARNING, 'deprecated'); $level_human = JError::translateErrorLevel($error->get('level')); if (isset($_SERVER['HTTP_HOST'])) { // Output as html jexit("<br /><b>J{$level_human}</b>: " . $error->get('message') . "<br />\n"); } else { // Output as simple text if (defined('STDERR')) { fwrite(STDERR, "J{$level_human}: " . $error->get('message') . "\n"); jexit(); } else { jexit("J{$level_human}: " . $error->get('message') . "\n"); } } return $error; }
/** * Die error handler * - Echos the error message to output and then dies * * @static * @param object $error Exception object to handle * @param array $options Handler options * @return object The exception object * @since 1.5 * * @see raise() */ function &handleDie(&$error, $options) { $level_human = JError::translateErrorLevel($error->get('level')); if (isset($_SERVER['HTTP_HOST'])) { // output as html die("<br /><b>J{$level_human}</b> " . $error->get('message') . "<br />\n"); } else { // output as simple text if (defined('STDERR')) { fwrite(STDERR, "J{$level_human} " . $error->get('message') . "\n"); } else { die("J{$level_human} " . $error->get('message') . "\n"); } } return $error; }
function raiseError($error) { $output = array(); $output[] = JError::translateErrorLevel($error->get('level')) . ' ' . $error->get('code') . ': '; if ($error->get('message')) { $output[] = $error->get('message'); } if ($error->get('line')) { $output[] = ' IN LINE ' . $error->get('line'); } if ($error->get('function')) { $text = ' IN '; if ($error->get('class')) { $text = $error->get('class') . '::'; } $text = $error->get('function'); $output[] = $text; } if ($error->get('file')) { $output[] = 'IN FILE ' . $error->get('file'); } exit($this->json_encode(array('result' => '', 'error' => implode("\n", $output)))); }