示例#1
0
 /**
  * Display an error message
  *
  * @param	string	the error message
  * @param	string	any "swap" values
  * @param	bool	whether to localize the message
  * @return	string	sends the application/views/errors/error_db.php template
  */
 public function display_error($error = '', $swap = '', $native = FALSE)
 {
     // First load the language
     Language::get('db');
     $heading = Language::line('db_error_heading');
     if ($native === TRUE) {
         $message = (array) $error;
     } else {
         $message = is_array($error) ? $error : array(str_replace('%s', $swap, Language::line($error)));
     }
     // Find the most likely culprit of the error by going through
     // the backtrace until the source file is no longer in the
     // database folder.
     $trace = debug_backtrace();
     foreach ($trace as $call) {
         if (isset($call['file'], $call['class'])) {
             // We'll need this on Windows, as APPPATH and BASEPATH will always use forward slashes
             if (DIRECTORY_SEPARATOR !== '/') {
                 $call['file'] = str_replace('\\', '/', $call['file']);
             }
             if (strpos($call['file'], Core::$coreDir . DS . 'Database') === FALSE && strpos($call['class'], 'Loader') === FALSE) {
                 // Found it - use a relative path for safety
                 $message[] = 'Filename: ' . str_replace(array('Application', 'Core'), '', $call['file']);
                 $message[] = 'Line Number: ' . $call['line'];
                 break;
             }
         }
     }
     Logger::logError($heading);
     foreach ($message as $message) {
         Logger::logError($message);
     }
     Logger::http_error(500);
     exit(8);
     // EXIT_DATABASE
 }
示例#2
0
文件: Email.php 项目: fuzeworks/core
 /**
  * Set Message
  *
  * @param	string	$msg
  * @param	string	$val = ''
  * @return	void
  */
 protected function _set_error_message($msg, $val = '')
 {
     Language::get('email');
     if (sscanf($msg, 'lang:%s', $line) !== 1 or FALSE === ($line = Language::line($line))) {
         $this->_debug_msg[] = str_replace('%s', $val, $msg) . '<br />';
     } else {
         $this->_debug_msg[] = str_replace('%s', $val, $line) . '<br />';
     }
 }