Example #1
0
 /**
  * @todo: catch getPrevious() exception
  *
  * @param object $exception Exception
  *
  * @return multitype:multitype:Ambigous <NULL, unknown>
  */
 public function getExceptionArray($exception)
 {
     $_trace = [];
     foreach ($exception->getTrace() as $key => $item) {
         $_trace[$key] = ['file' => isset($item['file']) ? $item['file'] : null, 'line' => isset($item['line']) ? $item['line'] : null, 'function' => isset($item['function']) ? $item['function'] : null, 'class' => isset($item['class']) ? $item['class'] : null];
     }
     return ['message' => $exception->getMessage(), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'requestUri' => isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null, 'serverName' => isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null, 'date' => date('d.m.Y H:i'), 'trace' => $_trace, 'ip' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null, 'get' => Yii::$app->request->get(), 'post' => Yii::$app->request->post()];
 }
Example #2
0
 /**
  * Обработчик непойманых исключений
  *
  * @param object $exception - объект исключения
  */
 public static function handleException($exception)
 {
     ob_end_clean_all();
     $detals = array();
     $detals['File'] = str_replace([ROOT_PATH, '\\'], ['', '/'], $exception->getFile());
     $detals['Line'] = $exception->getLine();
     $detals['Msg'] = $exception->getMessage();
     Error::e503($detals);
 }
Example #3
0
 /**
  * Gets Information (message, code, file, line, trace) of an Exception.
  *
  * @param object $oE Exception object.
  * @return string
  */
 public static function getInfoExcept($oE)
 {
     $sDebug = $oE->getMessage();
     $sDebug .= '<br />';
     $sDebug = $oE->getCode();
     $sDebug .= '<br />';
     $sDebug = $oE->getFile();
     $sDebug .= '<br />';
     $sDebug = $oE->getLine();
     $sDebug .= '<br />';
     $sDebug .= $oE->getTraceAsString();
     return $sDebug;
 }
Example #4
0
 /**
  *  Метод для записи логов
  *  @param object $e Объект класса Exception
  *  @return bool Вернет истину если файл запишется
  */
 public function writeLog($e)
 {
     $datetime = date('d/m/y H:i:s');
     $msg = date('d/m/y H:i:s') . '||';
     $msg .= 'Код: ' . $e->getCode() . '||';
     $msg .= 'Сообщение: ' . $e->getMessage() . '||';
     $msg .= 'Линия: ' . $e->getLine() . '||';
     $msg .= 'Файл: ' . $e->getFile() . "\n";
     if (!file_put_contents(Config::LOGS, $msg, FILE_APPEND | LOCK_EX)) {
         return false;
     } else {
         return true;
     }
 }
Example #5
0
 /**
  * Render the backtrace
  *
  * @return  string  The contents of the backtrace
  */
 public function renderBacktrace()
 {
     $contents = null;
     $backtrace = $this->error->getTrace();
     if (is_array($backtrace)) {
         ob_start();
         $j = 1;
         $html = array();
         $html[] = '<table class="backtrace">';
         $html[] = '	<caption>Call stack</caption>';
         $html[] = '	<thead>';
         $html[] = '		<tr>';
         $html[] = '			<th scope="col">#</th>';
         $html[] = '			<th scope="col">Function</th>';
         $html[] = '			<th scope="col">Location</th>';
         $html[] = '		</tr>';
         $html[] = '	</thead>';
         $html[] = '	<tbody>';
         $html[] = '		<tr>';
         $html[] = '			<th scope="row">0</th>';
         $html[] = '			<td><span class="msg">!! ' . $this->error->getMessage() . ' !!</span></td>';
         $html[] = '			<td><span class="fl">' . $this->rooted($this->error->getFile()) . '</span>:<span class="ln">' . $this->error->getLine() . '</span></td>';
         $html[] = '		</tr>';
         for ($i = count($backtrace) - 1; $i >= 0; $i--) {
             $html[] = '		<tr>';
             $html[] = '			<th scope="row">' . $j . '</th>';
             if (isset($backtrace[$i]['class'])) {
                 $html[] = '			<td><span class="cls">' . $backtrace[$i]['class'] . '</span><span class="opn">' . $backtrace[$i]['type'] . '</span><span class="mtd">' . $backtrace[$i]['function'] . '</span>()</td>';
             } else {
                 $html[] = '			<td><span class="fnc">' . $backtrace[$i]['function'] . '</span>()</td>';
             }
             if (isset($backtrace[$i]['file'])) {
                 $html[] = '			<td><span class="fl">' . $this->rooted($backtrace[$i]['file']) . '</span>:<span class="ln">' . $backtrace[$i]['line'] . '</span></td>';
             } else {
                 $html[] = '			<td>&#160;</td>';
             }
             $html[] = '		</tr>';
             $j++;
         }
         $html[] = '	</tbody>';
         $html[] = '</table>';
         echo "\n" . implode("\n", $html) . "\n";
         $contents = ob_get_contents();
         ob_end_clean();
     }
     return $contents;
 }
Example #6
0
 /**
  * User exception handler
  *
  * @param  object $exc hold error data
  * @return void
  **/
 public static function exceptionHandler($exc)
 {
     $errno = $exc->getCode();
     $errmsg = $exc->getMessage();
     $filename = $exc->getFile();
     $linenum = $exc->getLine();
     $debug_array = $exc->getTrace();
     $back_trace = self::_errorBacktrace($debug_array);
     $err = self::_getOutputErrorMsg($errno, $errmsg, $filename, $linenum, $back_trace);
     BizSystem::logError($errno, "ExceptionHandler", $errmsg, null, $back_trace);
     if (defined('CLI') && CLI) {
         echo $err;
     } else {
         BizSystem::clientProxy()->showErrorMessage($err, true);
     }
     exit;
 }
Example #7
0
/**
 * Выводит исключение
 *
 * @param object $oException Исключение
 */
function rx_exception($oException)
{
    if (RUXON_DEBUG) {
        $title = 'Ruxon CMS: Исключение';
        $content = 'Исключение: ' . $oException->getMessage() . '<br />' . 'В файле: ' . $oException->getFile() . '<br />' . 'В строке: ' . $oException->getLine() . '<br />' . '<pre>' . $oException->getTraceAsString() . '</pre>';
    } else {
        $title = 'Ruxon CMS: Ошибка';
        $content = $oException->getMessage();
    }
    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>' . $title . '</title>
        </head>
        <body>
    ' . $content . '</body></html>';
}
Example #8
0
 /**
  * User exception handler
  *
  * @param  object $exc hold error data
  * @return void
  * */
 public static function exceptionHandler($exc)
 {
     $errno = $exc->getCode();
     $errmsg = $exc->getMessage();
     $filename = $exc->getFile();
     $linenum = $exc->getLine();
     $debug_array = $exc->getTrace();
     $back_trace = self::_errorBacktrace($debug_array);
     $err = self::_getOutputErrorMsg($errno, $errmsg, $filename, $linenum, $back_trace);
     Openbizx::$app->getLog()->logError($errno, "ExceptionHandler", $errmsg, null, $back_trace);
     if (defined('CLI') && CLI || self::$errorMode == 'text') {
         echo $err;
     } else {
         Openbizx::$app->getClientProxy()->showErrorMessage($err, true);
     }
     if (!$exc->no_exit) {
         Openbizx::$app->getClientProxy()->printOutput();
         exit;
     }
 }
/**
 * function called upon by global exception handler
 * 
 * @param object $e  exception  thrown
 * @return void
 */
function handleBadgerException($e)
{
    /**
     * Object containing global logging information
     * 
     * @var object
     */
    global $logger;
    echo "<b>";
    echo getBadgerTranslation2('badgerException', 'Error');
    echo "</b><br />";
    echo getBadgerTranslation2($e->getBadgerErrorPage(), $e->getBadgerErrorId());
    /**
     * Compiled error message
     * 
     * @var string 
     */
    $loggedError = "ERROR: - ERROR Module: " . $e->getBadgerErrorPage() . ", ERROR Code: " . $e->getBadgerErrorId() . ", Error Description: " . getBadgerTranslation2($e->getBadgerErrorPage(), $e->getBadgerErrorId(), 'en') . " ON LINE " . $e->getLine() . " IN FILE " . $e->getFile() . " ADDITIONAL INFO " . $e->getAdditionalInfo();
    // compile error message to be logged
    $logger->log($loggedError);
    //write to log file
}
Example #10
0
 /**
  * Exception Handler
  *
  * Do not call this method directly. Function visibility is public because set_exception_handler does not allow for
  * protected method callbacks.
  *
  * @param  object $exception  The exception to be handled
  * @return bool
  */
 public function _handleException($exception)
 {
     $result = false;
     if ($this->isEnabled(self::TYPE_EXCEPTION)) {
         //Handle \Error Exceptions in PHP7
         if (class_exists('Error') && $exception instanceof \Error) {
             $message = $exception->getMessage();
             $file = $exception->getFile();
             $line = $exception->getLine();
             $type = E_ERROR;
             //Set to E_ERROR by default
             if ($exception instanceof \DivisionByZeroError) {
                 $type = E_WARNING;
             }
             if ($exception instanceof \AssertionError) {
                 $type = E_WARNING;
             }
             if ($exception instanceof \ParseError) {
                 $type = E_PARSE;
             }
             if ($exception instanceof \TypeError) {
                 $type = E_RECOVERABLE_ERROR;
             }
             $result = $this->_handleError($type, $message, $file, $line, $exception);
         } else {
             $result = $this->handleException($exception);
         }
     }
     //Let the normal error flow continue
     return $result;
 }
Example #11
0
 /**
  * Error handler
  *
  * @param object $e
  */
 public function exceptionHandler($e)
 {
     $message = "[<strong>Exception</strong>] \t" . $e->getFile() . ":" . $e->getLine() . " - " . $e->getMessage();
     $this->_errors[] = $message;
     $this->_writeErrorLog($message);
 }
 /**
  * Get an array of exception object properties.
  *
  * @param object           $value
  * @param \ReflectionClass $class
  * @param int              $options One of Presenter constants
  *
  * @return array
  */
 protected function getProperties($value, \ReflectionClass $class, $options = 0)
 {
     $props = array('<protected>message</protected>' => $value->getMessage(), '<protected>code</protected>' => $value->getCode(), '<protected>file</protected>' => $value->getFile(), '<protected>line</protected>' => $value->getLine(), '<private>previous</private>' => $value->getPrevious());
     return array_merge(array_filter($props), parent::getProperties($value, $class, $options));
 }
Example #13
0
 /**
  * adds an exception as error to the errors collection
  * this will end up in response.errors[]
  * 
  * @note exception meta data (file, line, trace) is only shown when debug mode is on (@see base::$debug)
  * 
  * @param object $exception        extending \Exception
  * @param string $friendly_message optional, @see jsonapi\error->set_friendly_message()
  * @param string $about_link       optional, @see jsonapi\error->set_about_link()
  */
 public function add_exception($exception, $friendly_message = null, $about_link = null)
 {
     $error_message = $exception->getMessage();
     $error_status = $exception->getCode();
     $new_error = new error($error_message, $friendly_message, $about_link);
     if ($error_status) {
         $new_error->set_http_status($error_status);
     }
     // meta data
     if (base::$debug) {
         $file = $exception->getFile();
         if ($file) {
             $file = str_replace($_SERVER['DOCUMENT_ROOT'] . '/', '', $file);
             $new_error->add_meta('file', $file);
         }
         $line = $exception->getLine();
         if ($line) {
             $new_error->add_meta('line', $line);
         }
         $trace = $exception->getTrace();
         if ($trace) {
             foreach ($trace as &$place) {
                 if (!empty($place['file'])) {
                     $place['file'] = str_replace($_SERVER['DOCUMENT_ROOT'] . '/', '', $place['file']);
                 }
             }
             $new_error->add_meta('trace', $trace);
         }
     }
     $this->add_error_object($new_error);
     $previous_exception = $exception->getPrevious();
     if ($previous_exception) {
         $this->add_exception($previous_exception);
     }
 }
Example #14
0
 /**
  * 解析异常信息
  * @param object $e
  * @return array
  */
 public function parseException($e)
 {
     $trace = $e->getTrace();
     $files = [];
     $pro = [];
     $sys = [];
     $gfile = $e->getFile();
     if (!empty($gfile)) {
         $files[] = ['file' => $gfile, 'line' => $e->getLine()];
     }
     foreach ($trace as $t) {
         if (!empty($t['file'])) {
             $files[] = ['file' => $t['file'], 'line' => $t['line']];
         }
     }
     foreach ($files as $t) {
         if (!empty($t['file'])) {
             $file = $t['file'];
             unset($t['file']);
             if (strpos($file, H2O_PATH) !== false) {
                 $sys[$file][] = $t['line'];
             } else {
                 $pro[$file][] = $t['line'];
             }
         }
     }
     $files = array_merge($pro, $sys);
     return ['message' => $e->getMessage(), 'files' => $files];
 }
 /**
  * Log API exceptions and print error to screen if required
  *
  * @param object $e
  * @param string $tterrorstr
  * @param boolean $toscreen
  */
 public static function handle_exceptions($e, $tterrorstr = "", $toscreen = true, $embedded = false)
 {
     $errorstr = "";
     if (!empty($tterrorstr)) {
         $errorstr = get_string($tterrorstr, 'turnitintooltwo') . "<br/><br/>";
         if ($embedded == true) {
             $errorstr .= get_string('tii_submission_failure', 'turnitintooltwo') . "<br/><br/>";
         }
     }
     if (is_callable(array($e, 'getFaultCode'))) {
         $errorstr .= get_string('faultcode', 'turnitintooltwo') . ": " . $e->getFaultCode() . " | ";
     }
     if (is_callable(array($e, 'getFile'))) {
         $errorstr .= get_string('file') . ": " . $e->getFile() . " | ";
     }
     if (is_callable(array($e, 'getLine'))) {
         $errorstr .= get_string('line', 'turnitintooltwo') . ": " . $e->getLine() . " | ";
     }
     if (is_callable(array($e, 'getMessage'))) {
         $errorstr .= get_string('message', 'turnitintooltwo') . ": " . $e->getMessage() . " | ";
     }
     if (is_callable(array($e, 'getCode'))) {
         $errorstr .= get_string('code', 'turnitintooltwo') . ": " . $e->getCode();
     }
     turnitintooltwo_activitylog($errorstr, "API_ERROR");
     if ($toscreen) {
         turnitintooltwo_print_error($errorstr, null);
     } else {
         if ($embedded) {
             return $errorstr;
         }
     }
 }
Example #16
0
 /**
  * make a string md5 identification hash out of a log object/message to avoid duplicate log messages. first parameter
  * can either be a single string, array std object, or instance of exception.
  *
  * @error 11509
  * @param string|array|object|Exception $mixed expects a log object/message
  * @return string the md5 hash
  */
 protected static function hashify($mixed)
 {
     $tmp = array();
     if ($mixed instanceof Exception) {
         $tmp[] = (string) $mixed->getMessage();
         $tmp[] = (string) $mixed->getFile();
         $tmp[] = (string) $mixed->getLine();
     } else {
         foreach ((array) $mixed as $m) {
             $tmp[] = (string) $m;
         }
     }
     return md5(mb_strtolower(trim(implode('', $tmp))));
 }
Example #17
0
 /**
  * output the error message. Requires the Exception object
  *
  * @param object $e
  */
 private function error_string($e, $errors = null)
 {
     $errors = !empty($errors) ? $errors : pg_last_error($this->dbh);
     echo "<table cellpadding=\"4\" cellspacing=\"4\" width=\"98%\" \n\t\t\t\t\t style=\"border: 1px solid #990000;background-color:#eee;\n\t\t\t\t\t margin:10px;\">\n\t\t\t  <tr>\n\t\t\t\t<td><b style=\"color:#990000;\"><u>db error:</u><b></td>\n\t\t\t\t<td>" . $e->getMessage() . "</td>\n\t\t\t  </tr>\n\t\t\t  <tr>\n\t\t\t  \t<td><b style=\"color:#990000;\"><u>file:</u><b></td>\n\t\t\t\t<td>" . $e->getFile() . " [line " . $e->getLine() . "]</td>\n\t\t\t  </tr>\n\t\t\t  <tr>\n\t\t\t  \t<td><b style=\"color:#990000;\"><u>db message:</u><b></td>\n\t\t\t\t<td>" . $errors . "</td>\n\t\t\t  </tr>\n\t\t\t</table>";
 }
 /**
  * log_slim_exception
  * Parses and logs slim exceptions for Statamic's logger
  *
  * @param object  $exception  Slim Exception
  * @return void
  */
 public static function log_slim_exception($exception)
 {
     $filename = $exception->getFile();
     $message = $exception->getLine() && !preg_match("/line [\\d]+/i", $exception->getMessage()) ? $exception->getMessage() . " on line " . $exception->getLine() . "." : $exception->getMessage();
     $aspect = 'unknown';
     $instance = 'unknown';
     if (strstr($filename, "/") !== FALSE) {
         preg_match("#/vendor/([\\w\\d\\-_]+)/#i", $filename, $matches);
         $path_info = pathinfo($filename);
         $instance = $path_info['filename'];
         $aspect = isset($matches[1]) ? $matches[1] : "core";
     }
     // log this as a fatal message
     self::fatal($message, $aspect, $instance);
 }
 /**
  * Exception handler, catches exceptions that are not in a try/catch block
  * @param 	object 	$exception		the exception object
  */
 public static function exceptionHandler($exception)
 {
     $err = array('errno' => static::_msgType('exception'), 'errstr' => $exception->getMessage(), 'errfile' => $exception->getFile(), 'errline' => $exception->getLine());
     static::_buildBuffer('log', '{errorHandler}', $err);
 }
Example #20
0
 /**
  * Logs System Exceptions to DataBase
  *
  * @access public
  * @param object $exception
  * @return void
  */
 public static function logError($exception)
 {
     try {
         $connection = new PDO('mysql:host=' . FOTOBAR_DB_HOST . ';dbname=' . FOTOBAR_DB_NAME, FOTOBAR_DB_USER, FOTOBAR_DB_AUTH);
         $sql = "INSERT INTO presswise_error_log (message, file, line, trace) VALUES (:message,:file,:line,:trace)";
         $q = $connection->prepare($sql);
         $q->execute(array(':message' => $exception->getMessage(), ':file' => $exception->getFile(), ':line' => $exception->getLine(), ':trace' => $exception->getTraceAsString()));
     } catch (Exception $e) {
         var_dump($e);
     }
 }
Example #21
0
 /**
  * Logs System Exceptions to DataBase
  *
  * @param object $exception
  * @access public
  * @return void
  */
 public static function logError($exception)
 {
     try {
         $connection = Netsuite_Db_Db::getInstance();
         $sth = $connection->prepare(Netsuite_Db_Query::getQuery('LOG_ERROR'));
         if (!$sth) {
             throw new Exception(explode(',', $sth->errorInfo()));
         }
         $sth->execute(array(':message' => $exception->getMessage(), ':file' => $exception->getFile(), ':line' => $exception->getLine(), ':trace' => $exception->getTraceAsString()));
     } catch (Exception $e) {
         var_dump($e);
     }
 }
Example #22
0
 /**
  * Carrega a página de erro de acordo com as configurações e mata a execução
  * @param	object	$error	instância de Exception
  * @return	void
  */
 private function loadError($error)
 {
     Error::render($error->getCode(), $error->getMessage(), $error->getFile(), $error->getLine(), $error->getTraceAsString(), method_exists($error, 'getDetails') ? $error->getDetails() : '');
 }
Example #23
0
 /**
  * 将异常信息记录到$this->_error中
  *
  * @param object $e            
  * @return string
  */
 private function soapFaultMsg($e)
 {
     $this->_error = $e->getMessage() . $e->getFile() . $e->getLine() . $e->getTraceAsString();
 }
 /**
  * Prepare a response in case an error occurred.
  *
  * @param object $exception \Exception or \Throwable
  * @param Http\Response $response
  * @return void
  */
 protected function prepareErrorResponse($exception, Http\Response $response)
 {
     $pathPosition = strpos($exception->getFile(), 'Packages/');
     $filePathAndName = $pathPosition !== false ? substr($exception->getFile(), $pathPosition) : $exception->getFile();
     $exceptionCodeNumber = $exception->getCode() > 0 ? '#' . $exception->getCode() . ': ' : '';
     $content = PHP_EOL . 'Uncaught Exception in Flow ' . $exceptionCodeNumber . $exception->getMessage() . PHP_EOL;
     $content .= 'thrown in file ' . $filePathAndName . PHP_EOL;
     $content .= 'in line ' . $exception->getLine() . PHP_EOL . PHP_EOL;
     $content .= Debugger::getBacktraceCode($exception->getTrace(), false, true) . PHP_EOL;
     if ($exception instanceof Exception) {
         $statusCode = $exception->getStatusCode();
     } else {
         $statusCode = 500;
     }
     $response->setStatus($statusCode);
     $response->setContent($content);
     $response->setHeader('X-Flow-ExceptionCode', $exception->getCode());
     $response->setHeader('X-Flow-ExceptionMessage', $exception->getMessage());
 }
Example #25
0
/**
 * 自定义异常处理
 *
 * @author          mrmsl <*****@*****.**>
 * @date            2012-09-12 13:30:32
 * @lastmodify      2013-01-22 17:13:09 by mrmsl
 *
 * @param object $e 异常
 *
 * @return void 无返回值
 */
function exception_handler($e)
{
    $message = $e->__toString();
    error_handler(E_APP_EXCEPTION, $e->getMessage(), $e->getFile(), $e->getLine(), '__' . $e->getTraceAsString());
}
Example #26
0
/**
 * 自定义异常处理
 *
 * @author          mrmsl <*****@*****.**>
 * @date            2012-09-12 13:30:32
 * @lastmodify      2013-01-22 17:13:09 by mrmsl
 *
 * @param object $e 异常
 *
 * @return void 无返回值
 */
function exception_handler($e)
{
    $message = $e->__toString();
    //入库
    sys_config('sys_log_systemerror') && D('Log')->addLog(nl2br($message), LOG_TYPE_SYSTEM_ERROR);
    error_handler(E_APP_EXCEPTION, $e->getMessage(), $e->getFile(), $e->getLine(), '__' . $e->getTraceAsString());
}
Example #27
0
 /**
  * This method is called when an exception occurs
  * @param  object $exception The incoming Exception object
  * @return null
  * @hidden
  */
 public function errorhandler($exception)
 {
     header("HTTP/1.1 500 Internal Server Error");
     $errstr = $exception->getMessage();
     $errcode = $exception->getCode();
     $backtrace = $exception->getTrace();
     // the same should not be outputted more than once
     if ($errstr == $this->lasterror) {
         return;
     }
     $this->lasterror = $errstr;
     // count errors to produce unique ids
     $this->errorcounter++;
     // if it is an error throw away the first backtrace item
     if ($exception instanceof ErrorException) {
         array_shift($backtrace);
     }
     // add actual error to backtrace
     $bt['file'] = $exception->getFile();
     $bt['line'] = $exception->getLine();
     array_unshift($backtrace, $bt);
     // clean array
     $backtrace_keys = array('file' => '', 'line' => '', 'class' => '', 'object' => '', 'type' => '', 'function' => '', 'args' => array());
     foreach ($backtrace as $key => $value) {
         $backtrace[$key] = array_merge($backtrace_keys, $value);
     }
     // set the error code string
     if ($exception instanceof ErrorException) {
         $errordescription = $this->errortypes[$exception->getSeverity()];
     } elseif ($errcode == 0) {
         $errordescription = 'EXCEPTION';
     } else {
         $errordescription = 'EXCEPTION (Code ' . $errcode . ')';
     }
     // show error on screen
     if ($this->config['output']['screen'] == true) {
         $error = $this->_errorhandler_output($errstr, $backtrace, $errordescription);
         echo $error;
     }
     // log error in logfile
     if ($this->config['output']['file'] == true) {
         $this->_errorhandler_file($errstr, $backtrace, $errordescription);
     }
     // "execute after exception" function
     if ($this->_after_exception !== null) {
         $call = $this->_after_exception;
         $call($exception);
     }
 }
Example #28
0
 /**
  * Normalises a backtrace.
  *
  * @param  array|object $backtrace A backtrace array or an exception instance.
  * @return array                   A backtrace array.
  */
 public static function normalise($backtrace)
 {
     if (!$backtrace instanceof Exception) {
         return $backtrace;
     }
     return array_merge([['function' => '[NA]', 'file' => $backtrace->getFile(), 'line' => $backtrace->getLine(), 'args' => []]], $backtrace->getTrace());
 }
Example #29
0
 /**
  * 将异常信息记录到$this->_error中
  *
  * @param object $e            
  * @return string
  */
 private function soapFaultMsg($e)
 {
     $this->_error = $e->getMessage() . $e->getFile() . $e->getLine() . $e->getTraceAsString();
     throw new SoapFault($e->getCode(), $e->getMessage());
 }
Example #30
0
 /**
  * Triggers a warning via email to the system administrator
  * 
  * @access public static
  * @param string $text Error Message
  * @param object $error Object of diagnostic of the errors
  * @return void
  */
 public static function fireAlert($text, $error)
 {
     $head = 'MIME-Version: 1.1' . PHP_EOL;
     $head .= 'Content-type: text/html; charset=utf-8' . PHP_EOL;
     $head .= 'From: Automatic Alert <*****@*****.**>' . PHP_EOL;
     $head .= 'Return-Path: Automatic Alert <*****@*****.**>' . PHP_EOL;
     $body = 'Diagnostic alert:<br /><br /><b>' . $error->getMessage() . '</b><br />' . $error->getFile() . ' : ' . $error->getLine();
     if (static::PDO4YOU_FIREALERT) {
         @mail(static::PDO4YOU_WEBMASTER, $text, $body, $head);
     }
 }