当前位置: 首页>>代码示例>>PHP>>正文


PHP exception::getTraceAsString方法代码示例

本文整理汇总了PHP中exception::getTraceAsString方法的典型用法代码示例。如果您正苦于以下问题:PHP exception::getTraceAsString方法的具体用法?PHP exception::getTraceAsString怎么用?PHP exception::getTraceAsString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在exception的用法示例。


在下文中一共展示了exception::getTraceAsString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: header

 /**
  * Static s_display_error
  */
 static function generic_display_error(exception $ex)
 {
     $title = $ex->getMessage();
     $err_no = $ex->getCode();
     if (!class_exists('loader') || class_exists('loader') && !loader::in_ajax()) {
         header('', true, 500);
         $message = '<style>* {font: 0.97em verdana;} a {text-decoration:none;background:#EFEFEF;padding:4px;} a:hover{background: red;}</style><h1>Ups! We have an error here.</h1>';
         $subject = "Error " . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
         $message .= 'Visit <a href="/">index</a> page.<br/><br/>';
         echo $message;
         // if debug
         if (class_exists('core') && core::is_debug()) {
             echo '<br/>Error : ' . $title . ' : ' . $err_no;
             echo '<br/><br/>' . nl2br($ex->getTraceAsString());
         }
     }
 }
开发者ID:rustyJ4ck,项目名称:moswarBot,代码行数:20,代码来源:exception.php

示例2: showError

    /**
     * Sends an errormessage (html) to the user
     *
     * @access public
     * @static
     * @param exception $exception Instanz of an exception
     */
    public function showError($exception)
    {
        /* flush cache */
        ob_clean();
        ob_start();
        /* display html */
        ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>phpMedaDB :: Exception</title>
	<style type="text/css">
<!--
	body { font-size:12px; font-family:monospace; }
	h1 { font-size:18px; color:red; }
	.phpmediadb-body-exception { background-color:#FFFFCC; border:1px dashed grey; margin-bottom:10px; padding:5px; }
	.phpmediadb-body-exception-code { background-color:#FAFAFA; border:1px dotted grey; margin:10px; padding:5px; }
	.phpmediadb-body-exception-copyright { text-align:right; }
-->
	</style>
</head>

<body>
<div class="phpmediadb-body-exception">
	<h1>Ouch, got an exception...</h1>
	Sorry but I was not able to complete your request. Please try again.
<?php 
        if (constant('PHPMEDIADB_SYSTEM_DEBUGLEVEL') >= 1) {
            ?>
	<br /><br />
	<b>Exception Details:</b>
	<div class="phpmediadb-body-exception-code"><pre><?php 
            echo htmlentities($exception->getMessage());
            ?>
</pre></div>
<?php 
        }
        ?>
</div>

<?php 
        if (constant('PHPMEDIADB_SYSTEM_DEBUGLEVEL') >= 2) {
            ?>
<div class="phpmediadb-body-exception">
	<h1>Debug</h1>
	<b>Stack trace:</b><br />
	<div class="phpmediadb-body-exception-code"><pre><?php 
            echo htmlentities($exception->getTraceAsString());
            ?>
</pre></div>
	<br />
	<b>File:</b> <?php 
            echo htmlentities($exception->getFile());
            ?>
 <b>Line:</b> <?php 
            echo htmlentities($exception->getLine());
            ?>
</div>
<?php 
        }
        ?>
<div class="phpmediadb-body-exception-copyright">
	phpMediaDB :: The media database<br />
	Version <?php 
        echo PHPMEDIADB_SYSTEM_VERSION;
        ?>
</div>
</body>
</html><?php 
    }
开发者ID:BackupTheBerlios,项目名称:phpmediadb,代码行数:77,代码来源:class.phpmediadb_exception.php

示例3: handle_exception

 /**
  * Displays an exception in HTML, and exists. Includes the exception
  * trace in an HTML comment, and a readable error string along with the
  * exception message.
  * @param exception $e Exception
  */
 public static function handle_exception($e)
 {
     // Display actual trace in HTML comment. There shouldn't be any
     // security-sensitive information in the trace, so this can be
     // displayed even on live server (I hope).
     if (debugging('', DEBUG_DEVELOPER)) {
         global $CFG;
         print "<pre class='forumng-stacktrace'>";
         print htmlspecialchars(str_replace($CFG->dirroot, '', $e->getTraceAsString()));
         print "</pre>";
     } else {
         print "<!--\n";
         print $e->getTraceAsString();
         // Not escaped, I think this is correct...
         print "\n-->";
     }
     // Make a short version of the trace string for log
     $minitrace = self::get_minitrace_part($e->getFile(), $e->getLine());
     foreach ($e->getTrace() as $entry) {
         $minitrace .= ' ' . self::get_minitrace_part($entry['file'], $entry['line']);
     }
     $minitrace = shorten_text($minitrace, 120, true);
     $message = shorten_text($e->getMessage(), 120, true);
     global $FULLME, $USER, $CFG;
     $url = str_replace($CFG->wwwroot . '/mod/forumng/', '', $FULLME);
     add_to_log(0, 'forumng', 'error', $url, "{$message} / {$minitrace}", 0, $USER->id);
     // Error to user with just the message
     print_error('error_exception', 'forumng', '', $e->getMessage());
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:35,代码来源:forum_utils.php

示例4: prompt


//.........这里部分代码省略.........
             if ($matches) {
                 continue;
             }
             // If one of the parsers didn't catch the message
             // fall through to the built-in commands
             switch (strtolower($input)) {
                 case 'help':
                     $out = array();
                     $out[] = 'For the PHP Simple Daemon debugging guide, see: ';
                     $out[] = 'https://github.com/shaneharter/PHP-Daemon/wiki/Debugging-Workers';
                     $out[] = '';
                     $out[] = 'Available Commands:';
                     $out[] = 'y                 Step to the next break point';
                     $out[] = 'n                 Interrupt';
                     $out[] = '';
                     $out[] = 'capture           Call the current method and capture its return value. Will print_r the return value and return a prompt.';
                     $out[] = 'end               End the debugging session, continue the daemon as normal.';
                     $out[] = 'help              Print This Help';
                     $out[] = 'kill              Kill the daemon and all of its worker processes.';
                     $out[] = 'skip              Skip this breakpoint from now on.';
                     $out[] = 'shutdown          End Debugging and Gracefully shutdown the daemon after the current loop_interval.';
                     $out[] = 'trace             Print A Stack Trace';
                     if (is_callable($this->indent_callback)) {
                         $out[] = 'indent [y|n]      When turned-on, indentation will be used to group messages from the same call in a column so you can easily match them together.';
                     }
                     $out[] = '';
                     foreach ($this->parsers as $parser) {
                         $out[] = sprintf('%s%s', str_pad($parser['command'], 18, ' ', STR_PAD_RIGHT), $parser['description']);
                     }
                     $out[] = '';
                     $out[] = '!!                Repeat previous command';
                     $printer(implode(PHP_EOL, $out));
                     break;
                 case 'indent y':
                     $this->debug_state('indent', true);
                     $printer('Indent enabled');
                     break;
                 case 'indent n':
                     $this->debug_state('indent', false);
                     $printer('Indent disabled');
                     break;
                 case 'show args':
                     $printer(print_r($args, true));
                     break;
                 case 'shutdown':
                     //$this->daemon->shutdown();
                     $printer("Shutdown In Progress... Use `end` command to cease debugging until shutdown is complete.");
                     $break = true;
                     break;
                 case 'trace':
                     $e = new exception();
                     $printer($e->getTraceAsString());
                     break;
                 case 'end':
                     $this->debug_state('enabled', false);
                     $break = true;
                     $printer('Debugging Ended..');
                     $input = true;
                     break;
                 case 'skip':
                     $this->debug_state("skip_{$method}", true);
                     $printer('Breakpoint "' . $method . '" Turned Off..');
                     $break = true;
                     $input = true;
                     break;
                 case 'kill':
                     @fclose(STDOUT);
                     @fclose(STDERR);
                     @exec('ps -C "php ' . Core_Daemon::get('filename') . '" -o pid= | xargs kill -9 ');
                     break;
                 case 'capture':
                     $backtrace = debug_backtrace();
                     if ($backtrace[1]['function'] !== '__call' || $method == self::CAPTURE) {
                         $printer('Cannot capture this :(');
                         break;
                     }
                     $input = self::CAPTURE;
                     $break = true;
                     break;
                 case 'y':
                     $input = self::CONT;
                     $break = true;
                     break;
                 case 'n':
                     $input = self::ABORT;
                     $break = true;
                     break;
                 default:
                     if ($input) {
                         $printer("Unknown Command! See `help` for list of commands.");
                     }
             }
         }
     } catch (Exception $e) {
         $this->mutex_release();
         throw $e;
     }
     $this->mutex_release();
     return $input;
 }
开发者ID:adnanrahim,项目名称:PHP-Daemon,代码行数:101,代码来源:DebugShell.php


注:本文中的exception::getTraceAsString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。