• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP exception类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了exception类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: generic_display_error

 /**
  * 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


示例3: import

 /**
  * 文件导入
  */
 public static function import($className, $type)
 {
     static $_file = array();
     //特殊字符转换
     $type = strtolower($type);
     if (isset($_file[$className])) {
         return true;
     }
     //判断文件类型 1=>action 2=>model -1=>其他文件
     $filetype = $type == 'action' ? 1 : ($type == 'model' ? 2 : -1);
     $flag = false;
     if ($filetype == 1) {
         $flag = self::importAction($className);
     } else {
         if ($filetype == 2) {
             $flag = self::importModel($className);
         } else {
             $flag = self::importOther($className);
         }
     }
     if (!$flag) {
         exception::halt(FILE_NOTFOUND, '文件:' . $className . '未找到');
     }
 }
开发者ID:beelibrary820145,项目名称:tanxiongfeng,代码行数:27,代码来源:LoadfileModel.class.php


示例4: errorAction

 /** 
  * Show YAF Error 
  * only display errors under DEV, else save error in LOG_FILE
  * @param exception $exception
  * @return void
  */
 public function errorAction($exception)
 {
     switch ($exception->getCode()) {
         case YAF_ERR_NOTFOUND_MODULE:
         case YAF_ERR_NOTFOUND_CONTROLLER:
         case YAF_ERR_NOTFOUND_ACTION:
         case YAF_ERR_NOTFOUND_VIEW:
             if (ENV == 'DEV') {
                 echo 404, ":", $exception->getMessage();
             } else {
                 echo 404;
                 file_put_contents(LOG_FILE, $exception->getMessage() . PHP_EOL, FILE_APPEND);
             }
             break;
         default:
             if (ENV == 'DEV') {
                 echo 0, ":", $exception->getMessage();
             } else {
                 echo 'Unknown error';
                 file_put_contents(LOG_FILE, $exception->getMessage() . PHP_EOL, FILE_APPEND);
             }
             break;
     }
 }
开发者ID:xn1224,项目名称:YOF,代码行数:30,代码来源:Error.php


示例5: addExceptionToScore

 private function addExceptionToScore(\exception $exception)
 {
     list($file, $line) = $this->getBacktrace($exception->getTrace());
     $this->score->addException($file, $this->class, $this->currentMethod, $line, $exception);
     return $this;
 }
开发者ID:hafeez3000,项目名称:atoum,代码行数:6,代码来源:test.php


示例6: error_message

 /**
  * Converts a Stripe exception into an error message.
  *
  * @param exception $exception
  *
  * @return string Error message.
  */
 public static function error_message($exception)
 {
     if ($exception instanceof Stripe_CardError) {
         $body = $exception->getJsonBody();
         $error = $body['error'];
         return sprintf(_x('Error code: <code>%1$s</code>. %2$s.', 's2member-front', 's2member'), esc_html(trim($error['code'], '.')), esc_html(trim($error['message'], '.')));
     }
     if ($exception instanceof Stripe_InvalidRequestError) {
         return _x('Invalid parameters to Stripe; please contact the site owner.', 's2member-front', 's2member');
     }
     if ($exception instanceof Stripe_AuthenticationError) {
         return _x('Invalid Stripe API keys; please contact the site owner.', 's2member-front', 's2member');
     }
     if ($exception instanceof Stripe_ApiConnectionError) {
         return _x('Network communication failure with Stripe; please try again.', 's2member-front', 's2member');
     }
     if ($exception instanceof Stripe_Error) {
         return _x('Stripe API error; please try again.', 's2member-front', 's2member');
     }
     return _x('Stripe error; please try again.', 's2member-front', 's2member');
 }
开发者ID:JalpMi,项目名称:v2contact,代码行数:28,代码来源:stripe-utilities.inc.php


示例7: testRun

 public function testRun()
 {
     $this->given($pusher = new testedClass(__FILE__), $pusher->setTaggerEngine($taggerEngine = new \mock\mageekguy\atoum\scripts\tagger\engine()), $pusher->setGit($git = new \mock\mageekguy\atoum\cli\commands\git()), $pusher->setErrorWriter($errorWriter = new \mock\mageekguy\atoum\writers\std\err()), $pusher->setInfoWriter($infoWriter = new \mock\mageekguy\atoum\writers\std\out()), $this->calling($infoWriter)->write = $infoWriter)->assert('Pusher should write error if tag file is not readable')->if($this->calling($errorWriter)->write = $errorWriter, $this->function->file_get_contents = false)->then->object($pusher->run())->isIdenticalTo($pusher)->mock($errorWriter)->call('write')->withArguments('Unable to read \'' . $pusher->getTagFile() . '\'')->once()->assert('Pusher should write error if tag file is not writable')->if($this->calling($errorWriter)->write = $errorWriter, $this->function->file_put_contents = false, $this->function->file_get_contents = '0.0.0')->then->object($pusher->run())->isIdenticalTo($pusher)->mock($errorWriter)->call('write')->withArguments('Unable to write in \'' . $pusher->getTagFile() . '\'')->once()->assert('Pusher should tag code and commit it if tag file is writable')->if($this->function->file_put_contents = function ($path, $data) {
         return strlen($data);
     }, $this->calling($taggerEngine)->tagVersion->doesNothing(), $this->calling($git)->addAllAndCommit = $git, $this->calling($git)->checkoutAllFiles = $git, $this->calling($git)->createTag = $git, $this->calling($git)->push = $git, $this->calling($git)->forcePush = $git, $this->calling($git)->pushTag = $git, $this->calling($git)->resetHardTo = $git, $this->calling($git)->deleteLocalTag = $git)->then->object($pusher->run())->isIdenticalTo($pusher)->function('file_put_contents')->wasCalledWithArguments($pusher->getTagFile(), '0.0.1')->once()->mock($taggerEngine)->call('tagVersion')->before($this->mock($git)->call('addAllAndCommit')->withArguments('Set version to 0.0.1.')->before($this->mock($git)->call('createTag')->withArguments('0.0.1')->before($this->mock($git)->call('push')->withArguments($pusher->getRemote())->once())->before($this->mock($git)->call('pushTag')->withArguments('0.0.1', $pusher->getRemote())->once())->once())->once())->after($this->mock($taggerEngine)->call('setSrcDirectory')->withArguments($pusher->getWorkingDirectory())->once())->after($this->mock($taggerEngine)->call('setVersion')->withArguments('$Rev:' . ' 0.0.1 $')->once())->once()->call('tagVersion')->before($this->mock($git)->call('addAllAndCommit')->withArguments('Set version to dev-master.')->once())->after($this->mock($taggerEngine)->call('setSrcDirectory')->withArguments($pusher->getWorkingDirectory())->once())->after($this->mock($taggerEngine)->call('setVersion')->withArguments('$Rev:' . ' dev-master $')->once())->once()->if($pusher->tagPatchVersion())->then->object($pusher->run())->isIdenticalTo($pusher)->function('file_put_contents')->wasCalledWithArguments($pusher->getTagFile(), '0.0.1')->twice()->if($pusher->tagMinorVersion())->then->object($pusher->run())->isIdenticalTo($pusher)->function('file_put_contents')->wasCalledWithArguments($pusher->getTagFile(), '0.1.0')->once()->if($pusher->tagMajorVersion())->then->object($pusher->run())->isIdenticalTo($pusher)->function('file_put_contents')->wasCalledWithArguments($pusher->getTagFile(), '1.0.0')->once()->assert('Pusher should write error if pushing tag failed and should try to reset repository')->if($pusher->tagPatchVersion(), $this->calling($git)->pushTag->throw = $exception = new \exception(uniqid()))->then->object($pusher->run())->isIdenticalTo($pusher)->mock($errorWriter)->call('write')->withArguments($exception->getMessage())->once()->mock($git)->call('resetHardTo')->withArguments('HEAD~2')->once()->call('deleteLocalTag')->withArguments('0.0.1')->once()->assert('Pusher should write error if pushing commit failed and should try to reset repository')->if($this->calling($git)->push->throw = $exception = new \exception(uniqid()))->then->object($pusher->run())->isIdenticalTo($pusher)->mock($errorWriter)->call('write')->withArguments($exception->getMessage())->once()->mock($git)->call('resetHardTo')->withArguments('HEAD~2')->once()->call('deleteLocalTag')->withArguments('0.0.1')->once()->assert('Pusher should write error if pushing commit for DEVELOPMENT version failed and should try to reset repository')->if($this->calling($git)->push = $git, $this->calling($git)->addAllAndCommit[2]->throw = $exception = new \exception(uniqid()))->then->object($pusher->run())->isIdenticalTo($pusher)->mock($errorWriter)->call('write')->withArguments($exception->getMessage())->once()->mock($git)->call('resetHardTo')->withArguments('HEAD~1')->once()->assert('Pusher should write error if pushing commit for DEVELOPMENT version failed and should try to reset repository')->if($this->calling($git)->createTag->throw = $exception = new \exception(uniqid()))->then->object($pusher->run())->isIdenticalTo($pusher)->mock($errorWriter)->call('write')->withArguments($exception->getMessage())->once()->mock($git)->call('resetHardTo')->withArguments('HEAD~1')->once()->assert('Pusher should write error if commit failed for STABLE version and should try to reset repository')->if($this->calling($git)->createTag = $git, $this->calling($git)->addAllAndCommit[1]->throw = $exception = new \exception(uniqid()))->then->object($pusher->run())->isIdenticalTo($pusher)->mock($errorWriter)->call('write')->withArguments($exception->getMessage())->after($this->mock($git)->call('addAllAndCommit'))->once()->mock($git)->call('checkoutAllFiles')->after($this->mock($git)->call('addAllAndCommit'))->once()->assert('Pusher should write error if reset failed')->if($this->calling($git)->checkoutAllFiles->throw = $checkoutAllFilesException = new \exception(uniqid()))->then->object($pusher->run())->isIdenticalTo($pusher)->mock($errorWriter)->call('write')->withArguments($checkoutAllFilesException->getMessage())->once();
 }
开发者ID:xihewang,项目名称:atoum,代码行数:6,代码来源:pusher.php


示例8: send_error

    /**
     * Send the error information to the WS client
     * formatted as XML document.
     * @param exception $ex
     * @return void
     */
    protected function send_error($ex = null)
    {
        // Zend Soap server fault handling is incomplete compared to XML-RPC :-(
        // we can not use: echo $this->zend_server->fault($ex);
        //TODO: send some better response in XML
        if ($ex) {
            $info = $ex->getMessage();
            if (debugging() and isset($ex->debuginfo)) {
                $info .= ' - ' . $ex->debuginfo;
            }
        } else {
            $info = 'Unknown error';
        }
        $xml = '<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body><SOAP-ENV:Fault>
<faultcode>MOODLE:error</faultcode>
<faultstring>' . $info . '</faultstring>
</SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>';
        $this->send_headers();
        header('Content-Type: application/xml; charset=utf-8');
        header('Content-Disposition: inline; filename="response.xml"');
        echo $xml;
    }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:30,代码来源:locallib.php


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


示例10: log

 /**
  * Virhelogi
  *
  * @param string  $message   Virheviesti
  * @param exception $exception Exception
  * @param string  $type      Kirjataanko tuote vai tilauslogiin
  */
 public function log($message, $exception = '', $type = 'product')
 {
     if (self::LOGGING == true) {
         $timestamp = date('d.m.y H:i:s');
         $message = utf8_encode($message);
         if ($exception != '') {
             $message .= " (" . $exception->getMessage() . ") faultcode: " . $exception->faultcode;
         }
         $message .= "\n";
         $log_location = $type == 'product' ? '/tmp/magento_log.txt' : '/tmp/magento_order_log.txt';
         error_log("{$timestamp}: {$message}", 3, $log_location);
     }
 }
开发者ID:Hermut,项目名称:pupesoft,代码行数:20,代码来源:magento_client.php


示例11: text

 /**
  * Get a single line of text representing the exception:
  *
  * Error [ Code ]: Message ~ File [ Line ]
  *
  * @param   object  Exception
  * @return  string
  */
 public static function text(exception $e)
 {
     return sprintf('Message: %s ERROR: %s Code:[ %s ] Fiel: %s ~ Line [ %d ]', strip_tags($e->getMessage()), get_class($e), $e->getCode(), $e->getFile(), $e->getLine());
 }
开发者ID:CrazyBobik,项目名称:allotaxi.test,代码行数:12,代码来源:exception.php


示例12: addErrorToDisplay

 /**
  * adds a exception to the array of displayed exceptions for the view
  * by default is displayed in the inc_header, but with the custom destination set to true
  * the exception won't be displayed by default but can be displayed where ever wanted in the tpl
  *
  * @param exception $oEr                 a exception object or just a language local (string) which will be converted into a oxExceptionToDisplay object
  * @param bool      $blFull              if true the whole object is add to display (default false)
  * @param bool      $blCustomDestination true if the exception shouldn't be displayed at the default position (default false)
  * @param string    $sCustomDestination  defines a name of the view variable containing the messages, overrides Parameter 'CustomError' ("default")
  * @param string    $sActiveController   defines a name of the controller, which should handle the error.
  */
 public function addErrorToDisplay($oEr, $blFull = false, $blCustomDestination = false, $sCustomDestination = "", $sActiveController = "")
 {
     if ($blCustomDestination && (oxRegistry::getConfig()->getRequestParameter('CustomError') || $sCustomDestination != '')) {
         // check if the current request wants do display exceptions on its own
         $sDestination = oxRegistry::getConfig()->getRequestParameter('CustomError');
         if ($sCustomDestination != '') {
             $sDestination = $sCustomDestination;
         }
     } else {
         //default
         $sDestination = 'default';
     }
     //starting session if not yet started as all exception
     //messages are stored in session
     $oSession = $this->getSession();
     if (!$oSession->getId() && !$oSession->isHeaderSent()) {
         $oSession->setForceNewSession();
         $oSession->start();
     }
     $aEx = oxRegistry::getSession()->getVariable('Errors');
     if ($oEr instanceof oxException) {
         $oEx = oxNew('oxExceptionToDisplay');
         $oEx->setMessage($oEr->getMessage());
         $oEx->setExceptionType(get_class($oEr));
         if ($oEr instanceof oxSystemComponentException) {
             $oEx->setMessageArgs($oEr->getComponent());
         }
         $oEx->setValues($oEr->getValues());
         $oEx->setStackTrace($oEr->getTraceAsString());
         $oEx->setDebug($blFull);
         $oEr = $oEx;
     } elseif ($oEr && !$oEr instanceof oxIDisplayError) {
         // assuming that a string was given
         $sTmp = $oEr;
         $oEr = oxNew('oxDisplayError');
         $oEr->setMessage($sTmp);
     } elseif ($oEr instanceof oxIDisplayError) {
         // take the object
     } else {
         $oEr = null;
     }
     if ($oEr) {
         $aEx[$sDestination][] = serialize($oEr);
         oxRegistry::getSession()->setVariable('Errors', $aEx);
         if ($sActiveController == '') {
             $sActiveController = oxRegistry::getConfig()->getRequestParameter('actcontrol');
         }
         if ($sActiveController) {
             $aControllerErrors[$sDestination] = $sActiveController;
             oxRegistry::getSession()->setVariable('ErrorController', $aControllerErrors);
         }
     }
 }
开发者ID:ioanok,项目名称:symfoxid,代码行数:64,代码来源:oxutilsview.php


示例13: handle_exceptions

/**
 * Function handle_exceptions
 *
 * * @param exception $e
 * @return void
 */
function handle_exceptions(exception $e)
{
    global $msg;
    $trace = $e->getTrace();
    file_put_contents(_LOG_PATH_ . 'admin.exception.log', print_r($trace, true), FILE_APPEND);
    $msg .= $e->getMessage();
    return 'logout';
}
开发者ID:ramdesh,项目名称:Program-O,代码行数:14,代码来源:index.php


示例14: send_error

    /**
     * Send the error information to the WS client
     * formatted as an XML document.
     *
     * @param exception $ex the exception to send back
     */
    protected function send_error($ex = null)
    {
        if ($ex) {
            $info = $ex->getMessage();
            if (debugging() and isset($ex->debuginfo)) {
                $info .= ' - ' . $ex->debuginfo;
            }
        } else {
            $info = 'Unknown error';
        }
        $xml = '<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body><SOAP-ENV:Fault>
<faultcode>MOODLE:error</faultcode>
<faultstring>' . $info . '</faultstring>
</SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>';
        $this->send_headers();
        header('Content-Type: application/xml; charset=utf-8');
        header('Content-Disposition: inline; filename="response.xml"');
        echo $xml;
    }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:27,代码来源:locallib.php


示例15: __construct

 /**
  * generate a HTML2PDF exception
  *
  * @param    int $err error number
  * @param    mixed $other additionnal informations
  * @return   string  $html optionnal code HTML associated to the error
  */
 public final function __construct($err = 0, $other = null, $html = '')
 {
     // read the error
     switch ($err) {
         case 1:
             // Unsupported tag
             $msg = HTML2PDF_locale::get('err01');
             $msg = str_replace('[[OTHER]]', $other, $msg);
             $this->_tag = $other;
             break;
         case 2:
             // too long sentence
             $msg = HTML2PDF_locale::get('err02');
             $msg = str_replace('[[OTHER_0]]', $other[0], $msg);
             $msg = str_replace('[[OTHER_1]]', $other[1], $msg);
             $msg = str_replace('[[OTHER_2]]', $other[2], $msg);
             break;
         case 3:
             // closing tag in excess
             $msg = HTML2PDF_locale::get('err03');
             $msg = str_replace('[[OTHER]]', $other, $msg);
             $this->_tag = $other;
             break;
         case 4:
             // tags closed in the wrong order
             $msg = HTML2PDF_locale::get('err04');
             $msg = str_replace('[[OTHER]]', print_r($other, true), $msg);
             break;
         case 5:
             // unclosed tag
             $msg = HTML2PDF_locale::get('err05');
             $msg = str_replace('[[OTHER]]', print_r($other, true), $msg);
             break;
         case 6:
             // image can not be loaded
             $msg = HTML2PDF_locale::get('err06');
             $msg = str_replace('[[OTHER]]', $other, $msg);
             $this->_image = $other;
             break;
         case 7:
             // too big TD content
             $msg = HTML2PDF_locale::get('err07');
             break;
         case 8:
             // SVG tag not in DRAW tag
             $msg = HTML2PDF_locale::get('err08');
             $msg = str_replace('[[OTHER]]', $other, $msg);
             $this->_tag = $other;
             break;
         case 9:
             // deprecated
             $msg = HTML2PDF_locale::get('err09');
             $msg = str_replace('[[OTHER_0]]', $other[0], $msg);
             $msg = str_replace('[[OTHER_1]]', $other[1], $msg);
             $this->_tag = $other[0];
             break;
         case 0:
             // specific error
         // specific error
         default:
             $msg = $other;
             break;
     }
     // create the HTML message
     $this->_messageHtml = '<span style="color: #AA0000; font-weight: bold;">' . HTML2PDF_locale::get('txt01', 'error: ') . $err . '</span><br>';
     $this->_messageHtml .= HTML2PDF_locale::get('txt02', 'file:') . ' ' . $this->file . '<br>';
     $this->_messageHtml .= HTML2PDF_locale::get('txt03', 'line:') . ' ' . $this->line . '<br>';
     $this->_messageHtml .= '<br>';
     $this->_messageHtml .= $msg;
     // create the text message
     $msg = HTML2PDF_locale::get('txt01', 'error: ') . $err . ' : ' . strip_tags($msg);
     // add the optionnal html content
     if ($html) {
         $this->_messageHtml .= "<br><br>HTML : ..." . trim(htmlentities($html)) . '...';
         $this->_html = $html;
         $msg .= ' HTML : ...' . trim($html) . '...';
     }
     // save the other informations
     $this->_other = $other;
     // construct the exception
     parent::__construct($msg, $err);
 }
开发者ID:roger-jb,项目名称:edeip,代码行数:89,代码来源:exception.class.php


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


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


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


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


示例20: get_exception_info

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP exchange类代码示例发布时间:2022-05-23
下一篇:
PHP ewiki_db类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap