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


PHP Exception::getFile方法代码示例

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


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

示例1: exceptionHandle

 public static function exceptionHandle(Exception $exception)
 {
     if (DEBUG_MODE) {
         //直接输出调试信息
         echo nl2br($exception->__toString());
         echo '<hr /><p>Router:</p><pre>';
         print_r(Singleton::getInstance('Router'));
         echo '</pre>';
     } else {
         $code = $exception->getCode();
         $message = nl2br($exception->getMessage());
         /*
                     如果错误码"可能为"合法的http状态码则尝试设置,
                     setStatus()方法会忽略非法的http状态码. */
         if ($code >= 400 && $code <= 505 && !headers_sent()) {
             ResponseModule::setStatus($code);
         }
         $var_list = array('message' => $message, 'code' => $code, 'file' => $exception->getFile(), 'url' => Singleton::getInstance('Router')->getUrl());
         if ($error_file = self::_getErrorFilePath($code)) {
             Lugit::$view = new View($var_list);
             Lugit::$view->render($error_file);
         } else {
             echo 'No error page is found.<pre>';
             print_r($var_list);
             echo '</pre>';
         }
     }
     exit;
 }
开发者ID:sujinw,项目名称:php-lugit-framework,代码行数:29,代码来源:Basic.php

示例2: showException

 /**
  * Show exception screen
  *
  * @param \Exception $exception
  */
 public function showException(\Exception $exception)
 {
     @ob_end_clean();
     $msg = sprintf("%s\nFile: %s\nLine: %d\nTrace:\n%s", $exception->getMessage(), $exception->getFile(), $exception->getLine(), $exception->getTraceAsString());
     \Kalibri::logger()->add(Logger::L_EXCEPTION, $msg);
     $viewName = \Kalibri::config()->get('error.view.exception');
     if ($viewName) {
         $view = new \Kalibri\View($viewName);
         $view->ex = $exception;
         $str = '';
         $file = \fopen($exception->getFile(), 'r');
         for ($i = 0; $i < $exception->getLine() - 16; $i++) {
             \fgets($file);
         }
         for ($i = 0; $i < 20; $i++) {
             $str .= \fgets($file);
         }
         $view->code = Highlight::php($str, true, 1, $exception->getLine());
         if ($view->isExists()) {
             $view->render();
         } else {
             // Fallback to show any message in case if exception view not found or not set
             echo "<h1>Exception</h1><p>{$exception->getMessage()}</p>";
         }
     }
     exit;
 }
开发者ID:tenebras,项目名称:kalibri,代码行数:32,代码来源:Error.php

示例3: format

 /**
  * If detailed errors are enabled, just format the exception into
  * a simple error message and display it.
  *
  * @param \Exception $exception
  *
  * @return string
  */
 public static function format(\Exception $exception)
 {
     if (Sapi::isCli()) {
         return "+++ Untreated Exception +++" . PHP_EOL . "Message: " . $exception->getMessage() . PHP_EOL . "Location: " . $exception->getFile() . " on line " . $exception->getLine() . PHP_EOL . "Stack Trace: " . PHP_EOL . $exception->getTraceAsString() . PHP_EOL;
     }
     return "<html><h2>Untreated Exception</h2>\n      <h3>Message:</h3>\n      <pre>" . $exception->getMessage() . "</pre>\n      <h3>Location:</h3>\n      <pre>" . $exception->getFile() . " on line " . $exception->getLine() . "</pre>\n      <h3>Stack Trace:</h3>\n      <pre>" . $exception->getTraceAsString() . "</pre></html>";
 }
开发者ID:PermeAgility,项目名称:FrameworkBenchmarks,代码行数:15,代码来源:Error.php

示例4: format

 /**
  * If detailed errors are enabled, just format the exception into
  * a simple error message and display it.
  *
  * @param \Exception $exception
  * @param boolean    $isCli
  *
  * @return string
  */
 public static function format(\Exception $exception, $isCli = false)
 {
     if ($isCli === true) {
         return "+++ Untreated Exception +++" . PHP_EOL . "Message: " . $exception->getMessage() . PHP_EOL . "Location: " . $exception->getFile() . " on line " . $exception->getLine() . PHP_EOL . "Stack Trace: " . PHP_EOL . $exception->getTraceAsString() . PHP_EOL;
     }
     return "<html>\n    <head>\n      <style>\n        pre { display: block;\n            padding: 8.5px;\n            margin: 0 0 9px;\n            line-height: 18px;\n            word-break: break-all;\n            word-wrap: break-word;\n            white-space: pre;\n            white-space: pre-wrap;\n            border: 1px solid #ccc;\n            border: 1px solid rgba(0, 0, 0, 0.15);\n            -webkit-border-radius: 4px;\n            -moz-border-radius: 4px;\n            border-radius: 6px;\n            color: chartreuse;\n            background-color: black;\n        }\n      </style>\n    </head>\n      <h2>Untreated Exception</h2>\n      <h3>Message:</h3>\n      <pre>" . $exception->getMessage() . "</pre>\n      <h3>Location:</h3>\n      <pre>" . $exception->getFile() . " on line " . $exception->getLine() . "</pre>\n      <h3>Stack Trace:</h3>\n      <pre>" . $exception->getTraceAsString() . "</pre></html>";
 }
开发者ID:gjerokrsteski,项目名称:pimf-framework,代码行数:16,代码来源:Error.php

示例5: getCauseMessage

 /**
  * Function must be public to call on caused exceptions
  * 
  * @param  array
  * @return string
  */
 function getCauseMessage(&$causes)
 {
     $trace = $this->getTrace();
     $cause = array('class' => get_class($this), 'message' => $this->getMessage(), 'file' => 'unknown', 'line' => 'unknown');
     if (isset($trace[0])) {
         if (isset($trace[0]['file'])) {
             $cause['file'] = $trace[0]['file'];
             $cause['line'] = $trace[0]['line'];
         }
     }
     $causes[] = $cause;
     if ($this->cause instanceof Exception) {
         $this->cause->getCauseMessage($causes);
     } elseif ($this->cause instanceof Exception) {
         $causes[] = array('class' => get_class($this->cause), 'message' => $this->cause->getMessage(), 'file' => $this->cause->getFile(), 'line' => $this->cause->getLine());
     }
     if (is_array($this->cause)) {
         foreach ($this->cause as $cause) {
             if ($cause instanceof Exception || $cause instanceof Exception) {
                 $cause->getCauseMessage($causes);
             } elseif ($cause instanceof Exception) {
                 $causes[] = array('class' => get_class($cause), 'message' => $cause->getMessage(), 'file' => $cause->getFile(), 'line' => $cause->getLine());
             } elseif (is_array($cause) && isset($cause['message'])) {
                 // PEAR_ErrorStack warning
                 $causes[] = array('class' => $cause['package'], 'message' => $cause['message'], 'file' => isset($cause['context']['file']) ? $cause['context']['file'] : 'unknown', 'line' => isset($cause['context']['line']) ? $cause['context']['line'] : 'unknown');
             } else {
                 $causes[] = array('class' => null, 'message' => $cause, 'file' => null, 'line' => null);
             }
         }
     }
 }
开发者ID:jasny,项目名称:Q,代码行数:37,代码来源:Exception.php

示例6: getBacktrace

 /**
  * Get a backtrace for an exception.
  *
  * Optionally limit the number of rows to include with $count, and exclude
  * Psy from the trace.
  *
  * @param \Exception $e          The exception with a backtrace.
  * @param int        $count      (default: PHP_INT_MAX)
  * @param bool       $includePsy (default: true)
  *
  * @return array Formatted stacktrace lines.
  */
 protected function getBacktrace(\Exception $e, $count = null, $includePsy = true)
 {
     if ($cwd = getcwd()) {
         $cwd = rtrim($cwd, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
     }
     if ($count === null) {
         $count = PHP_INT_MAX;
     }
     $lines = array();
     $trace = $e->getTrace();
     array_unshift($trace, array('function' => '', 'file' => $e->getFile() !== null ? $e->getFile() : 'n/a', 'line' => $e->getLine() !== null ? $e->getLine() : 'n/a', 'args' => array()));
     if (!$includePsy) {
         for ($i = count($trace) - 1; $i >= 0; $i--) {
             $thing = isset($trace[$i]['class']) ? $trace[$i]['class'] : $trace[$i]['function'];
             if (preg_match('/\\\\?Psy\\\\/', $thing)) {
                 $trace = array_slice($trace, $i + 1);
                 break;
             }
         }
     }
     for ($i = 0, $count = min($count, count($trace)); $i < $count; $i++) {
         $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
         $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
         $function = $trace[$i]['function'];
         $file = isset($trace[$i]['file']) ? $this->replaceCwd($cwd, $trace[$i]['file']) : 'n/a';
         $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
         $lines[] = sprintf(' <class>%s</class>%s%s() at <info>%s:%s</info>', OutputFormatter::escape($class), OutputFormatter::escape($type), OutputFormatter::escape($function), OutputFormatter::escape($file), OutputFormatter::escape($line));
     }
     return $lines;
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:42,代码来源:TraceCommand.php

示例7: getFilteredStacktrace

 /**
  * Filters stack frames from PHPUnit classes.
  *
  * @param  Exception $e
  * @param  boolean   $asString
  * @return string
  */
 public static function getFilteredStacktrace(Exception $e, $asString = TRUE)
 {
     if (!defined('PHPUNIT_TESTSUITE')) {
         $blacklist = PHPUnit_Util_GlobalState::phpunitFiles();
     } else {
         $blacklist = array();
     }
     if ($asString === TRUE) {
         $filteredStacktrace = '';
     } else {
         $filteredStacktrace = array();
     }
     if ($e instanceof PHPUnit_Framework_SyntheticError) {
         $eTrace = $e->getSyntheticTrace();
     } else {
         $eTrace = $e->getTrace();
     }
     if (!self::frameExists($eTrace, $e->getFile(), $e->getLine())) {
         array_unshift($eTrace, array('file' => $e->getFile(), 'line' => $e->getLine()));
     }
     foreach ($eTrace as $frame) {
         if (isset($frame['file']) && is_file($frame['file']) && !isset($blacklist[$frame['file']])) {
             if ($asString === TRUE) {
                 $filteredStacktrace .= sprintf("%s:%s\n", $frame['file'], isset($frame['line']) ? $frame['line'] : '?');
             } else {
                 $filteredStacktrace[] = $frame;
             }
         }
     }
     return $filteredStacktrace;
 }
开发者ID:proofek,项目名称:phpunit,代码行数:38,代码来源:Filter.php

示例8: getFilteredStacktrace

 /**
  * Filters stack frames from PHPUnit classes.
  *
  * @param  Exception $e
  * @param  boolean   $filterTests
  * @param  boolean   $asString
  * @return string
  */
 public static function getFilteredStacktrace(Exception $e, $filterTests = TRUE, $asString = TRUE)
 {
     if ($asString === TRUE) {
         $filteredStacktrace = '';
     } else {
         $filteredStacktrace = array();
     }
     $groups = array('DEFAULT');
     if (!defined('PHPUNIT_TESTSUITE')) {
         $groups[] = 'PHPUNIT';
     }
     if ($filterTests) {
         $groups[] = 'TESTS';
     }
     $eTrace = $e->getTrace();
     if (!self::frameExists($eTrace, $e->getFile(), $e->getLine())) {
         array_unshift($eTrace, array('file' => $e->getFile(), 'line' => $e->getLine()));
     }
     foreach ($eTrace as $frame) {
         if (isset($frame['file']) && is_file($frame['file']) && !PHP_CodeCoverage::getInstance()->filter()->isFiltered($frame['file'], $groups, TRUE)) {
             if ($asString === TRUE) {
                 $filteredStacktrace .= sprintf("%s:%s\n", $frame['file'], isset($frame['line']) ? $frame['line'] : '?');
             } else {
                 $filteredStacktrace[] = $frame;
             }
         }
     }
     return $filteredStacktrace;
 }
开发者ID:strager,项目名称:phpunit,代码行数:37,代码来源:Filter.php

示例9: getBacktrace

 /**
  * Get a backtrace for an exception.
  *
  * Optionally limit the number of rows to include with $count, and exclude
  * Psy from the trace.
  *
  * @param \Exception $e          The exception with a backtrace.
  * @param int        $count      (default: PHP_INT_MAX)
  * @param bool       $includePsy (default: true)
  *
  * @return array Formatted stacktrace lines.
  */
 protected function getBacktrace(\Exception $e, $count = null, $includePsy = true)
 {
     if ($count === null) {
         $count = PHP_INT_MAX;
     }
     $lines = array();
     $trace = $e->getTrace();
     array_unshift($trace, array('function' => '', 'file' => $e->getFile() != null ? $e->getFile() : 'n/a', 'line' => $e->getLine() != null ? $e->getLine() : 'n/a', 'args' => array()));
     if (!$includePsy) {
         for ($i = count($trace) - 1; $i >= 0; $i--) {
             $thing = isset($trace[$i]['class']) ? $trace[$i]['class'] : $trace[$i]['function'];
             if (preg_match('/\\\\?Psy\\\\/', $thing)) {
                 $trace = array_slice($trace, $i + 1);
                 break;
             }
         }
     }
     for ($i = 0, $count = min($count, count($trace)); $i < $count; $i++) {
         $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
         $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
         $function = $trace[$i]['function'];
         $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
         $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
         $lines[] = sprintf(' %s%s%s() at <info>%s:%s</info>', $class, $type, $function, $file, $line);
     }
     return $lines;
 }
开发者ID:fulore,项目名称:psysh,代码行数:39,代码来源:TraceCommand.php

示例10: push

 /**
  * @param \Exception $objEx
  */
 public function push(\Exception $objEx)
 {
     $this->errorStackTraces[] = ['code' => $objEx->getCode(), 'file' => $objEx->getFile(), 'line' => $objEx->getLine(), 'msg' => $objEx->getMessage(), 'string' => $objEx->getTraceAsString()];
     if ($this->versionType === 'dev') {
         print sprintf('Exception in %s, line %s with message %s', $objEx->getFile(), $objEx->getLine(), $objEx->getMessage());
     }
 }
开发者ID:robotomize,项目名称:fujes,代码行数:10,代码来源:ExceptionWrap.php

示例11: exceptionHandler

/**
 * @param \Exception $e
 * @return bool
 */
function exceptionHandler(\Exception $e)
{
    echo '<h1>Error</h1><p>Sorry, the script died with a exception</p>';
    echo $e->getMessage() . ' in <br>' . $e->getFile() . ': <br>' . $e->getLine(), ' : <br>', __FUNCTION__, ' : <br>', $e->getTraceAsString();
    log::error($e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine() . "<br>\n", "Code: " . $e->getCode(), $e->getTrace());
    mail(ADMIN_MAIL, '[GitReminder] System got locked', $e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine() . "\n\n" . "Funktion -> " . __FUNCTION__ . $e->getTraceAsString() . "\n\n" . "Code: " . $e->getCode());
    @trigger_error('', E_USER_ERROR);
}
开发者ID:ADoebeling,项目名称:GitReminder,代码行数:12,代码来源:bootstrap.php

示例12: handleException

 public function handleException(Exception $exception)
 {
     $msg = "Uncaught Exception: " . $exception->getMessage() . "\n";
     $msg .= $exception->getMessage() . "\n";
     $msg .= 'Line: ' . $exception->getLine() . " in " . $exception->getFile();
     $msg .= "\n\nTrace Summary:\n" . self::traceFormat($exception->getTrace());
     if (ERROR_DISPLAY_MODE == 'html') {
         $msg .= "\nFull Trace: \n" . print_r($exception->getTrace(), 1);
     }
     $this->show($msg, $exception->getFile(), $exception->getLine(), $exception->getCode(), 'E_WARNING');
 }
开发者ID:MrYogi,项目名称:hasoffers-promotional-platform,代码行数:11,代码来源:ErrorHandler.php

示例13: exceptionMessage

 /**
  * @description Build message
  *
  * @return string
  */
 public function exceptionMessage()
 {
     $msg = '';
     if ($this->exception->getCode()) {
         $msg .= "Exception code: " . $this->exception->getCode() . PHP_EOL;
     }
     $msg .= $this->exception->getMessage() . PHP_EOL;
     $msg .= "At file: " . $this->exception->getFile();
     $msg .= ": " . $this->exception->getLine() . PHP_EOL;
     $msg .= "Trace: " . PHP_EOL . $this->exception->getTraceAsString();
     return $msg;
 }
开发者ID:ashterix,项目名称:exception-handler,代码行数:17,代码来源:BaseHandler.php

示例14: log_original_exception_message

 /**
  * Logs the original exception message.
  *
  * Provided as a manual override over the default `WP_DEBUG` dependent behaviour.
  *
  * @see Tribe__Exception::handle()
  *
  * @return bool  `true` if the message was logged, `false` otherwise.
  */
 private function log_original_exception_message()
 {
     if (!class_exists('Tribe__Log')) {
         return false;
     }
     $logger = new Tribe__Log();
     $message = $this->original_exception->getMessage();
     $log_type = $this->get_log_type_for_exception_code($this->original_exception->getCode());
     $src = $this->original_exception->getFile() . ':' . $this->original_exception->getLine();
     $logger->log($message, $log_type, $src);
     return true;
 }
开发者ID:nullify005,项目名称:shcc-website,代码行数:21,代码来源:Exception.php

示例15: Publish

 /**
  * Display errors in development and email them in release mode
  *
  * @param Exception $e
  * @param array $a_additional_info
  */
 public function Publish(Exception $e, array $a_additional_info)
 {
     // define an assoc array of error string
     // in reality the only entries we should
     // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
     // E_USER_WARNING and E_USER_NOTICE
     $error_types = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice');
     if (defined('E_STRICT')) {
         $error_types[E_STRICT] = 'Runtime Notice';
     }
     if (defined('E_RECOVERABLE_ERROR')) {
         $error_types[E_RECOVERABLE_ERROR] = 'Catchable Fatal Error';
     }
     # Build up information about the error
     $body = $e->getMessage() . "\n\n";
     if (!stristr($e->getFile(), 'exception-manager.class')) {
         $body .= $e->getFile() . ', line ' . $e->getLine() . "\n\n";
     }
     $trace = $e->getTraceAsString();
     if ($trace) {
         $body .= $trace . "\n\n";
     }
     if (array_key_exists($e->getCode(), $error_types)) {
         $body .= 'Code: ' . $error_types[$e->getCode()] . "\n";
     }
     # Get details of anything in additional_info
     ob_start();
     var_dump($a_additional_info);
     $body .= ob_get_contents();
     ob_end_clean();
     # What's the context?
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         foreach ($_POST as $key => $value) {
             $body .= '$POST[\'' . $key . '\']: ' . $value . "\n";
         }
     } else {
         foreach ($_GET as $key => $value) {
             $body .= '$GET[\'' . $key . '\']: ' . $value . "\n";
         }
     }
     foreach ($_SERVER as $key => $value) {
         $body .= '$SERVER[\'' . $key . '\']: ' . $value . "\n";
     }
     require_once 'Zend/Mail.php';
     $email = new Zend_Mail('UTF-8');
     $email->addTo($this->emailAddress);
     $email->setFrom('errors@' . $_SERVER['HTTP_HOST'], 'errors@' . $_SERVER['HTTP_HOST']);
     $email->setSubject('Error: ' . $e->getMessage());
     $email->setBodyText($body);
     $email->send();
 }
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:57,代码来源:email-exception-publisher.class.php


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