コード例 #1
0
 /**
  * Converts an exception into a simple string.
  *
  * @param \Exception $exception the exception being converted
  * @return string the string representation of the exception.
  */
 public static function convertExceptionToString($exception)
 {
     if ($exception instanceof Exception && ($exception instanceof UserException || !LEAPS_DEBUG)) {
         $message = "{$exception->getName()}: {$exception->getMessage()}";
     } elseif (LEAPS_DEBUG) {
         if ($exception instanceof Exception) {
             $message = "Exception ({$exception->getName()})";
         } elseif ($exception instanceof ErrorException) {
             $message = "{$exception->getName()}";
         } else {
             $message = 'Exception';
         }
         $message .= " '" . get_class($exception) . "' with message '{$exception->getMessage()}' \n\nin " . $exception->getFile() . ':' . $exception->getLine() . "\n\n" . "Stack trace:\n" . $exception->getTraceAsString();
     } else {
         $message = 'Error: ' . $exception->getMessage();
     }
     return $message;
 }
コード例 #2
0
ファイル: Exception.php プロジェクト: smallmirror62/framework
 /**
  * @return string readable representation of exception
  */
 public function __toString()
 {
     return parent::__toString() . PHP_EOL . 'Additional Information:' . PHP_EOL . print_r($this->errorInfo, true);
 }