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


PHP exception::getLine方法代码示例

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


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

示例1: panic

 public static function panic(\exception $e)
 {
     $response = Factory::make("response");
     $vars = [];
     $vars['message'] = $e->getMessage();
     $vars['file_line'] = $e->getFile() . " " . $e->getLine();
     $response->renderHtml("exception.html", $vars);
 }
开发者ID:longmonhau,项目名称:Half-Life,代码行数:8,代码来源:Kernel.php

示例2: get_exception_info

/**
 * Returns detailed information about specified exception.
 * @param exception $ex
 * @return object
 */
function get_exception_info($ex)
{
    global $CFG, $DB, $SESSION;
    if ($ex instanceof moodle_exception) {
        $errorcode = $ex->errorcode;
        $module = $ex->module;
        $a = $ex->a;
        $link = $ex->link;
        $debuginfo = $ex->debuginfo;
    } else {
        $errorcode = 'generalexceptionmessage';
        $module = 'error';
        $a = $ex->getMessage();
        $link = '';
        $debuginfo = '';
    }
    // Append the error code to the debug info to make grepping and googling easier
    $debuginfo .= PHP_EOL . "Error code: {$errorcode}";
    $backtrace = $ex->getTrace();
    $place = array('file' => $ex->getFile(), 'line' => $ex->getLine(), 'exception' => get_class($ex));
    array_unshift($backtrace, $place);
    // Be careful, no guarantee moodlelib.php is loaded.
    if (empty($module) || $module == 'moodle' || $module == 'core') {
        $module = 'error';
    }
    // Search for the $errorcode's associated string
    // If not found, append the contents of $a to $debuginfo so helpful information isn't lost
    if (function_exists('get_string_manager')) {
        if (get_string_manager()->string_exists($errorcode, $module)) {
            $message = get_string($errorcode, $module, $a);
        } elseif ($module == 'error' && get_string_manager()->string_exists($errorcode, 'moodle')) {
            // Search in moodle file if error specified - needed for backwards compatibility
            $message = get_string($errorcode, 'moodle', $a);
        } else {
            $message = $module . '/' . $errorcode;
            $debuginfo .= PHP_EOL . '$a contents: ' . print_r($a, true);
        }
    } else {
        $message = $module . '/' . $errorcode;
        $debuginfo .= PHP_EOL . '$a contents: ' . print_r($a, true);
    }
    // Be careful, no guarantee weblib.php is loaded.
    if (function_exists('clean_text')) {
        $message = clean_text($message);
    } else {
        $message = htmlspecialchars($message);
    }
    if (!empty($CFG->errordocroot)) {
        $errordoclink = $CFG->errordocroot . '/en/';
    } else {
        $errordoclink = get_docs_url();
    }
    if ($module === 'error') {
        $modulelink = 'moodle';
    } else {
        $modulelink = $module;
    }
    $moreinfourl = $errordoclink . 'error/' . $modulelink . '/' . $errorcode;
    if (empty($link)) {
        if (!empty($SESSION->fromurl)) {
            $link = $SESSION->fromurl;
            unset($SESSION->fromurl);
        } else {
            $link = $CFG->wwwroot . '/';
        }
    }
    // when printing an error the continue button should never link offsite
    if (stripos($link, $CFG->wwwroot) === false && stripos($link, $CFG->httpswwwroot) === false) {
        $link = $CFG->wwwroot . '/';
    }
    $info = new stdClass();
    $info->message = $message;
    $info->errorcode = $errorcode;
    $info->backtrace = $backtrace;
    $info->link = $link;
    $info->moreinfourl = $moreinfourl;
    $info->a = $a;
    $info->debuginfo = $debuginfo;
    return $info;
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:85,代码来源:setuplib.php

示例3: get_exception_info

/**
 * Returns detailed information about specified exception.
 * @param exception $ex
 * @return object
 */
function get_exception_info($ex)
{
    global $CFG, $DB, $SESSION;
    if ($ex instanceof moodle_exception) {
        $errorcode = $ex->errorcode;
        $module = $ex->module;
        $a = $ex->a;
        $link = $ex->link;
        $debuginfo = $ex->debuginfo;
    } else {
        $errorcode = 'generalexceptionmessage';
        $module = 'error';
        $a = $ex->getMessage();
        $link = '';
        $debuginfo = '';
    }
    // Append the error code to the debug info to make grepping and googling easier
    $debuginfo .= PHP_EOL . "Error code: {$errorcode}";
    $backtrace = $ex->getTrace();
    $place = array('file' => $ex->getFile(), 'line' => $ex->getLine(), 'exception' => get_class($ex));
    array_unshift($backtrace, $place);
    // Be careful, no guarantee moodlelib.php is loaded.
    if (empty($module) || $module == 'moodle' || $module == 'core') {
        $module = 'error';
    }
    // Search for the $errorcode's associated string
    // If not found, append the contents of $a to $debuginfo so helpful information isn't lost
    if (function_exists('get_string_manager')) {
        if (get_string_manager()->string_exists($errorcode, $module)) {
            $message = get_string($errorcode, $module, $a);
        } elseif ($module == 'error' && get_string_manager()->string_exists($errorcode, 'moodle')) {
            // Search in moodle file if error specified - needed for backwards compatibility
            $message = get_string($errorcode, 'moodle', $a);
        } else {
            $message = $module . '/' . $errorcode;
            $debuginfo .= PHP_EOL . '$a contents: ' . print_r($a, true);
        }
    } else {
        $message = $module . '/' . $errorcode;
        $debuginfo .= PHP_EOL . '$a contents: ' . print_r($a, true);
    }
    // Remove some absolute paths from message and debugging info.
    $searches = array();
    $replaces = array();
    $cfgnames = array('tempdir', 'cachedir', 'localcachedir', 'themedir', 'dataroot', 'dirroot');
    foreach ($cfgnames as $cfgname) {
        if (property_exists($CFG, $cfgname)) {
            $searches[] = $CFG->{$cfgname};
            $replaces[] = "[{$cfgname}]";
        }
    }
    if (!empty($searches)) {
        $message = str_replace($searches, $replaces, $message);
        $debuginfo = str_replace($searches, $replaces, $debuginfo);
    }
    // Be careful, no guarantee weblib.php is loaded.
    if (function_exists('clean_text')) {
        $message = clean_text($message);
    } else {
        $message = htmlspecialchars($message);
    }
    if (!empty($CFG->errordocroot)) {
        $errordoclink = $CFG->errordocroot . '/en/';
    } else {
        $errordoclink = get_docs_url();
    }
    if ($module === 'error') {
        $modulelink = 'moodle';
    } else {
        $modulelink = $module;
    }
    $moreinfourl = $errordoclink . 'error/' . $modulelink . '/' . $errorcode;
    if (empty($link)) {
        if (!empty($SESSION->fromurl)) {
            $link = $SESSION->fromurl;
            unset($SESSION->fromurl);
        } else {
            $link = $CFG->wwwroot . '/';
        }
    }
    // When printing an error the continue button should never link offsite.
    // We cannot use clean_param() here as it is not guaranteed that it has been loaded yet.
    $httpswwwroot = str_replace('http:', 'https:', $CFG->wwwroot);
    if (stripos($link, $CFG->wwwroot) === 0) {
        // Internal HTTP, all good.
    } else {
        if (!empty($CFG->loginhttps) && stripos($link, $httpswwwroot) === 0) {
            // Internal HTTPS, all good.
        } else {
            // External link spotted!
            $link = $CFG->wwwroot . '/';
        }
    }
    $info = new stdClass();
    $info->message = $message;
//.........这里部分代码省略.........
开发者ID:janeklb,项目名称:moodle,代码行数:101,代码来源:setuplib.php

示例4: 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

示例5: get_exception_info

/**
 * Returns detailed information about specified exception.
 * @param exception $ex
 * @return object
 */
function get_exception_info($ex) {
    global $CFG, $DB, $SESSION;

    if ($ex instanceof moodle_exception) {
        $errorcode = $ex->errorcode;
        $module = $ex->module;
        $a = $ex->a;
        $link = $ex->link;
        $debuginfo = $ex->debuginfo;
    } else {
        $errorcode = 'generalexceptionmessage';
        $module = 'error';
        $a = $ex->getMessage();
        $link = '';
        $debuginfo = null;
    }

    $backtrace = $ex->getTrace();
    $place = array('file'=>$ex->getFile(), 'line'=>$ex->getLine(), 'exception'=>get_class($ex));
    array_unshift($backtrace, $place);

    // Be careful, no guarantee moodlelib.php is loaded.
    if (empty($module) || $module == 'moodle' || $module == 'core') {
        $module = 'error';
    }
    if (function_exists('get_string_manager')) {
        if (get_string_manager()->string_exists($errorcode, $module)) {
            $message = get_string($errorcode, $module, $a);
        } elseif ($module == 'error' && get_string_manager()->string_exists($errorcode, 'moodle')) {
            // Search in moodle file if error specified - needed for backwards compatibility
            $message = get_string($errorcode, 'moodle', $a);
        } else {
            $message = $module . '/' . $errorcode;
        }
    } else {
        $message = $module . '/' . $errorcode;
    }

    // Be careful, no guarantee weblib.php is loaded.
    if (function_exists('clean_text')) {
        $message = clean_text($message);
    } else {
        $message = htmlspecialchars($message);
    }

    if (!empty($CFG->errordocroot)) {
        $errordocroot = $CFG->errordocroot;
    } else if (!empty($CFG->docroot)) {
        $errordocroot = $CFG->docroot;
    } else {
        $errordocroot = 'http://docs.moodle.org';
    }
    if ($module === 'error') {
        $modulelink = 'moodle';
    } else {
        $modulelink = $module;
    }
    $moreinfourl = $errordocroot . '/en/error/' . $modulelink . '/' . $errorcode;

    if (empty($link)) {
        if (!empty($SESSION->fromurl)) {
            $link = $SESSION->fromurl;
            unset($SESSION->fromurl);
        } else {
            $link = $CFG->wwwroot .'/';
        }
    }

    $info = new stdClass();
    $info->message     = $message;
    $info->errorcode   = $errorcode;
    $info->backtrace   = $backtrace;
    $info->link        = $link;
    $info->moreinfourl = $moreinfourl;
    $info->a           = $a;
    $info->debuginfo   = $debuginfo;

    return $info;
}
开发者ID:nfreear,项目名称:moodle,代码行数:84,代码来源:setuplib.php

示例6: exceptionHandler

/**
 * Custom exception handler with backtrace
 * 
 * @param exception $exception Thrown exception
 * 
 * @return void
 */
function exceptionHandler($exception)
{
    global $dPconfig;
    $time = date("Y-m-d H:i:s");
    // User information
    $user_id = null;
    $user_view = "";
    if (class_exists("CAppUI", false) && CAppUI::$user) {
        $user = CAppUI::$user;
        if ($user->_id) {
            $user_id = $user->_id;
            $user_view = $user->_view;
        }
    }
    // Server IP
    $server_ip = isset($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : null;
    $file = mbRelativePath($exception->getFile());
    $line = $exception->getLine();
    $type = "exception";
    $text = $exception->getMessage();
    // Stacktrace
    $contexts = $exception->getTrace();
    foreach ($contexts as &$ctx) {
        unset($ctx['args']);
    }
    // Might noy be ready at the time error is thrown
    $session = isset($_SESSION) ? $_SESSION : array();
    unset($session['AppUI']);
    unset($session['dPcompteRendu']['templateManager']);
    $_all_params = array("GET" => $_GET, "POST" => $_POST, "SESSION" => $session);
    filterInput($_all_params);
    // CApp might not be ready yet as of early error handling
    $request_uid = null;
    if (class_exists("CApp", false)) {
        $request_uid = CApp::getRequestUID();
        CApp::$performance[CError::$_categories["exception"]]++;
    }
    $build_output = ini_get("display_errors");
    $save_to_file = false;
    $data = array("stacktrace" => $contexts, "param_GET" => $_all_params["GET"], "param_POST" => $_all_params["POST"], "session_data" => $_all_params["SESSION"]);
    if (@$dPconfig["error_logs_in_db"] && class_exists("CErrorLog")) {
        try {
            CErrorLog::insert($user_id, $server_ip, $time, $request_uid, $type, $text, $file, $line, $data);
        } catch (Exception $e) {
            $build_output = true;
            $save_to_file = true;
        }
    } else {
        $build_output = true;
        $save_to_file = true;
    }
    if ($build_output) {
        $hash = md5(serialize($contexts));
        $html_class = "big-warning";
        $log = "\n\n<div class='{$html_class}' title='{$hash}'>";
        if ($user_id) {
            $log .= "\n<strong>User: </strong>{$user_view} ({$user_id})";
        }
        $file = CError::openInIDE($file, $line);
        $log .= <<<HTML
  <strong>Time: </strong>{$time}
  <strong>Type: </strong>{$type}
  <strong>Text: </strong>{$text}
  <strong>File: </strong>{$file}
  <strong>Line: </strong>{$line}
HTML;
        foreach ($_all_params as $_type => $_params) {
            $log .= print_infos($_all_params[$_type], $_type);
        }
        foreach ($contexts as $context) {
            $function = isset($context["class"]) ? $context["class"] . ":" : "";
            $function .= $context["function"] . "()";
            $log .= "\n<strong>Function: </strong> {$function}";
            if (isset($context["file"])) {
                $log .= "\n<strong>File: </strong>" . CError::openInIDE($context["file"], isset($context["line"]) ? $context["line"] : null);
            }
            if (isset($context["line"])) {
                $log .= "\n<strong>Line: </strong>" . $context["line"];
            }
            $log .= "<br />";
        }
        $log .= "</div>";
        if ($save_to_file) {
            file_put_contents(LOG_PATH, $log, FILE_APPEND);
        }
        if (ini_get("display_errors")) {
            echo $log;
        }
    }
}
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:97,代码来源:errors.php

示例7: 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

示例8: handleException

    /**
     * Handle with exceptions
     *
     * @param exception $e
     */
    public function handleException($e)
    {
        $msg = '';
        $trace = $e->getTrace();
        ksort($trace);
        foreach ($trace as $error) {
            if (isset($error['function']) && isset($error['file'])) {
                $msg .= $error['file'] . '&nbsp;(' . $error['line'] . ') ';
                if (isset($error['function']) && is_string($error['function'])) {
                    $msg .= (isset($error['class']) ? $error['class'] . $error['type'] : '') . $error['function'] . '()';
                }
                $msg .= '<br />';
            }
        }
        echo <<<EOT
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>Akami Framework</title>
</head>
<body>
    <style>
        html, body {
            height: 100%;
            padding: 0;
            margin: 0;
        }

        body {
            width: 100%;
            display: table;

            background: #16938A;
            color: #333;
            font-size: 14px;
            line-height: 1.825;
            font-family: "Lucida Grande", Helvetica, Arial, "Microsoft YaHei", FreeSans, Arimo, "Droid Sans","wenquanyi micro hei","Hiragino Sans GB", "Hiragino Sans GB W3", Arial, sans-serif
        }

        .box {
            display: table-cell;
            vertical-align: middle;
        }

        .box .container {
            background: #fff;
            width: 500px;
            margin: 0 auto;
            padding: 2em;
            box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
            -webkit-box-sizing: border-box;
                    box-sizing: border-box;
        }

        header {
          color: #999;
          display: block;
          margin-bottom: 1em;
        }

        .bold {
          color: #222;
          font-weight: bold;
        }

        p {
            color: #222;
        }

        .message {
          color: #777;
          font-size: 12px;

          margin-top: 1em;
          margin-bottom: 0;
        }
    </style>
    <div class="box">
        <div class="container">
            <header>
              <span class="bold">Message Reminder</span>
               - {$e->getMessage()}
            </header>
            <p class="file"><span class="bold">Location: </span> {$e->getfile()} <i>({$e->getLine()})</i></p>
            <p class="message">{$msg}</p>
        </div>
    </div>
</body>
</html>
EOT;
    }
开发者ID:Kunr,项目名称:Akami,代码行数:97,代码来源:Akami.php


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