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


PHP Throwable::__toString方法代码示例

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


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

示例1: handler

 /**
  * Throwable handler.
  *
  * @since 160711 Throwables.
  *
  * @param \Throwable $Throwable Error/Exception.
  */
 public function handler(\Throwable $Throwable)
 {
     if ($this->c::isCli()) {
         // Set `STDERR` so that it can be used in CLI feedback.
         // If debugging, `STDERR` should include a full stack trace.
         // If it's not an interactive terminal session, try to log the error.
         // The exit status should always be `1` to indicate an error.
         try {
             // Catch throwables.
             $this->c::noCacheFlags();
             $this->c::sessionWriteClose();
             $this->c::obEndCleanAll();
             if ($this->App->Config->©debug['©enable']) {
                 $this->c::writeStderr($Throwable->__toString());
             } else {
                 $this->c::writeStderr($Throwable->getMessage());
             }
             if (!$this->c::isCliInteractive()) {
                 error_log(str_replace("", '', $Throwable->__toString()));
             }
             exit(1);
             // Exit status code.
             //
         } catch (\Throwable $inner_Throwable) {
             // Edge case.
             exit(1);
             // Simply exit in this edge case.
         }
     } elseif (!headers_sent()) {
         // Send a 500 error response code.
         // If there is a throwable template, use the throwable template.
         // In either case, rethrow; i.e., allow PHP to log as an error.
         // It's also IMPORTANT to rethrow so that execution stops!
         try {
             // Catch throwables.
             $this->c::noCacheFlags();
             $this->c::sessionWriteClose();
             $this->c::obEndCleanAll();
             $this->c::statusHeader(500);
             $this->c::noCacheHeaders();
             header('content-type: text/html; charset=utf-8');
             echo $this->c::getTemplate('http/html/status/500.php')->parse(['Throwable' => $Throwable]);
             //
         } catch (\Throwable $inner_Throwable) {
             echo 'Unexpected error. Please try again.' . "\n";
             // Edge case.
         }
         throw $Throwable;
         // Rethrow. i.e., allow PHP to log as an error.
         // ↑ NOTE: Assumes throwables will not be handled here when `display_errors=yes`.
         // Therefore, when the above template is displayed, that's all you'll see in most cases.
         // i.e., Under most conditions, the display of this PHP error should not be seen. Only logged.
     } else {
         // Should be avoided. It's always better to buffer output so that an error
         // can be shown instead of what would have been output to a browser otherwise.
         // Our own template handler uses output buffering so this is not an issue with core.
         throw $Throwable;
         // Rethrow. i.e., log and/or display if debugging.
     }
 }
开发者ID:websharks,项目名称:core,代码行数:67,代码来源:Throwables.php

示例2: onAppError

 private function onAppError($clientId, \Throwable $e) : \Generator
 {
     $this->logger->error($e->__toString());
     $code = Code::UNEXPECTED_SERVER_ERROR;
     $reason = "Internal server error, aborting";
     yield from $this->doClose($this->clients[$clientId], $code, $reason);
 }
开发者ID:dol,项目名称:aerys,代码行数:7,代码来源:Rfc6455Endpoint.php

示例3: onAppError

 private function onAppError($clientId, \Throwable $e) : \Generator
 {
     $this->logger->error($e->__toString());
     $code = Code::UNEXPECTED_SERVER_ERROR;
     $reason = "Internal server error, aborting";
     if (isset($this->clients[$clientId])) {
         // might have been already unloaded + closed
         yield from $this->doClose($this->clients[$clientId], $code, $reason);
     }
 }
开发者ID:staabm,项目名称:aerys,代码行数:10,代码来源:Rfc6455Endpoint.php

示例4: __toString

 /**
  * Returns a string representation of the handler
  *
  * @author Art <a.molcanovas@gmail.com>
  * @return string
  */
 public function __toString()
 {
     return parent::__toString() . self::EOL . 'Registered: ' . (self::$registered ? 'Yes' : 'No') . self::EOL . 'Previous exception recursion limit: ' . $this->config->prevExceptionDepth . self::EOL . 'Last reported exception: ' . (self::$lastReported ? self::$lastReported->__toString() : '[none]');
 }
开发者ID:aloframework,项目名称:handlers,代码行数:10,代码来源:ExceptionHandler.php


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