/** * Creates a detailed description of an exception which is used for exception mails, * exception info files and fatal exception views * * @param \Exception $e * @return string detailed description */ private function createDetailLogMessage(\Throwable $e) { // build title $eName = get_class($e); $title = 'An ' . $eName . ' occurred'; $debugContent = $title . PHP_EOL . str_repeat('+', mb_strlen($title)) . PHP_EOL . PHP_EOL; $debugContent .= $e->getMessage() . PHP_EOL . PHP_EOL; if ($e instanceof \ErrorException || $e instanceof \Error) { $debugContent .= 'File: ' . $e->getFile() . PHP_EOL . 'Line: ' . $e->getLine() . PHP_EOL . PHP_EOL; } // build query info for PDOExceptions if ($e instanceof QueryStumble) { $debugContent .= 'STATEMENT' . PHP_EOL . '---------' . PHP_EOL; $debugContent .= $e->getQueryString() . PHP_EOL . PHP_EOL; if ($e instanceof PdoPreparedExecutionException) { $boundValuesStr = ""; foreach ($e->getBoundValues() as $name => $value) { if (!mb_strlen($boundValuesStr)) { $boundValuesStr .= ', '; } $boundValuesStr .= $name . '=' . ReflectionUtils::buildScalar($value); } $debugContent .= 'Bound values: ' . $boundValuesStr . PHP_EOL . PHP_EOL; } } // build stack trace $debugContent .= 'STACK TRACE' . PHP_EOL . '-----------' . PHP_EOL; $debugContent .= $eName . ': ' . $e->getTraceAsString() . PHP_EOL; $curE = $e; while (null != ($curE = $curE->getPrevious())) { $debugContent .= PHP_EOL . get_class($curE) . ': ' . $this->createSimpleLogMessage($curE) . PHP_EOL . $curE->getTraceAsString() . PHP_EOL; } $debugContent .= PHP_EOL; if (isset($_SERVER['REQUEST_URI'])) { // build http request $debugContent .= 'HTTP REQUEST' . PHP_EOL . '------------' . PHP_EOL; $debugContent .= $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . PHP_EOL; foreach ($_SERVER as $name => $value) { if (stristr($name, 'HTTP_')) { $debugContent .= substr($name, 5) . "\t" . $value . PHP_EOL; } } } if (!$this->stable) { $debugContent .= 'VARS CANNOT BE DISPLAYED DUE TO UNSTABLE PHP STATE'; } else { $debugContent .= $this->createLogArrayStr('SERVER VARS', $_SERVER); if (!empty($_GET)) { $debugContent .= $this->createLogArrayStr('HTTP GET VARS', $_GET); } if (!empty($_POST)) { $debugContent .= $this->createLogArrayStr('HTTP POST VARS', $_POST); } } return $debugContent; }
private static function applyQueryStumble(ThrowableInfo $throwableInfo, QueryStumble $e) { $throwableInfo->setStatementString(SyntaxUtils::formatSql($e->getQueryString())); $boundValues = array(); foreach ((array) $e->getBoundValues() as $key => $value) { $boundValues[$key] = ReflectionUtils::buildScalar($value); } $throwableInfo->setBoundValues($boundValues); }