Get further information from Exception, if it has the property 'additionalData'
@param \Exception $e
@return string
@codeCoverageIgnore
775054
public static function getMoreInformationFromException(\Exception $e)
    {
        $default = 'No further information available.';
        if (!property_exists($e, 'additionalData')) {
            return $default;
        }
        if (!is_array($e->additionalData)) {
            return $default;
        }
        if (empty($e->additionalData)) {
            return $default;
        }
        $data = '<table>';
        foreach ($e->additionalData as $k => $v) {
            if (is_int($k) || is_string($k)) {
                $data .= '<tr>';
                $data .= '<td valign="top" class="cell-left width15p"><strong>' . $k . '</strong></td>';
                $data .= '<td valign="top" class="cell-right">';
                if (is_object($v)) {
                    $data .= '<xmp>' . serialize($v) . '</xmp>';
                } elseif (is_array($v)) {
                    $data .= '<xmp>' . json_encode($v) . '</xmp>';
                } else {
                    $data .= '<xmp>' . $v . '</xmp>';
                }
                $data .= '</td>';
                $data .= '</tr>';
            }
        }
        $data .= '</table>';

        return $data;
    }
221129
protected function getBacktrace(\Exception $exception)
    {
        $backtrace = array();

        $backtrace[] = '---';
        $backtrace[] = $this->getErrorMessage($exception);
        $backtrace[] = '---';

        // Allow marshalling of the trace: PHP marks getTraceAsString as final :-(
        if (method_exists($exception, 'getPreviousTraceAsString')) {
            $backtrace = array_merge($backtrace, explode("\n", $exception->getPreviousTraceAsString()));
        } else {
            $backtrace = array_merge($backtrace, explode("\n", $exception->getTraceAsString()));
        }

        if (($previous = $exception->getPrevious())) {
            $backtrace = array_merge($backtrace, $this->getBacktrace($previous)); // Recurse
        }

        return $backtrace;
    }
551985
protected function prepareException(Exception $e)
    {
        if ($e instanceof ModelNotFoundException) {
            $e = new NotFoundHttpException($e->getMessage(), $e);
        } elseif ($e instanceof AuthorizationException) {
            $e = new AccessDeniedHttpException($e->getMessage(), $e);
        } elseif ($e instanceof TokenMismatchException) {
            $e = new HttpException(419, $e->getMessage(), $e);
        }

        return $e;
    }
430716
public function getAdditionalData($key)
    {
        if (true === isset($this->additionalData[$key])) {
            return $this->additionalData[$key];
        }

        return null;
    }
286824
public static function translate(\Exception $e): \Exception
    {
        if ($e instanceof \Doctrine\DBAL\Exception\ConnectionException) {
            return new \Caridea\Dao\Exception\Unreachable("System unreachable or connection timed out", $e->getCode(), $e);
        } elseif ($e instanceof \Doctrine\ORM\EntityNotFoundException ||
                $e instanceof \Doctrine\ORM\UnexpectedResultException ||
                $e instanceof \Doctrine\ODM\MongoDB\DocumentNotFoundException ||
                $e instanceof \Doctrine\ODM\CouchDB\DocumentNotFoundException) {
            return new \Caridea\Dao\Exception\Unretrievable("Data could not be retrieved", 404, $e);
        } elseif ($e instanceof \Doctrine\ORM\PessimisticLockException ||
                $e instanceof \Doctrine\ORM\OptimisticLockException ||
                $e instanceof \Doctrine\ODM\CouchDB\OptimisticLockException) {
            return new \Caridea\Dao\Exception\Conflicting("Optimistic or pessimistic concurrency failure", 409, $e);
        } elseif ($e instanceof \Doctrine\DBAL\Exception\UniqueConstraintViolationException) {
            return new \Caridea\Dao\Exception\Duplicative("Unique constraint violation", 409, $e);
        } elseif ($e instanceof \Doctrine\DBAL\Exception\ConstraintViolationException) {
            return new \Caridea\Dao\Exception\Violating("Constraint violation", 422, $e);
        } elseif ($e instanceof \Doctrine\ORM\Query\QueryException ||
                $e instanceof \Doctrine\ORM\Mapping\MappingException ||
                $e instanceof \Doctrine\DBAL\Exception\SyntaxErrorException ||
                $e instanceof \Doctrine\Common\Persistence\Mapping\MappingException) {
            return new \Caridea\Dao\Exception\Inoperable("Invalid API usage", 0, $e);
        }
        return new \Caridea\Dao\Exception\Generic("Uncategorized database error", 0, $e);
    }
202315
private function handleExternalError(\Exception $e) {
        $reflection = new \ReflectionClass($e);
        echo '<header>';
            echo '<h1>Exception: ' . $reflection->getName() . '</h1>';
            echo '<h2>Message: ' . $e->getMessage() . '</h2>';
            echo '<h3>' . $e->getFile() . ':' . $e->getLine() . '</h3>';
        echo '</header>';
        if ( method_exists($e, 'getContext') ) {
            echo 'Debug:';
            !d( $e->getContext() );
        }
    }
532998
protected function get_error_from_exception($e)
    {
        $data = array();

        if ($e instanceof Crypt_GPG_KeyNotFoundException) {
            $error = enigma_error::KEYNOTFOUND;
            $data['id'] = $e->getKeyId();
        }
        else if ($e instanceof Crypt_GPG_BadPassphraseException) {
            $error = enigma_error::BADPASS;
            $data['bad']     = $e->getBadPassphrases();
            $data['missing'] = $e->getMissingPassphrases();
        }
        else if ($e instanceof Crypt_GPG_NoDataException) {
            $error = enigma_error::NODATA;
        }
        else if ($e instanceof Crypt_GPG_DeletePrivateKeyException) {
            $error = enigma_error::DELKEY;
        }
        else {
            $error = enigma_error::INTERNAL;
        }

        $msg = $e->getMessage();

        return new enigma_error($error, $msg, $data);
    }
947582
protected function convertExceptionToArray(Exception $e)
    {
        return $this->container->make('config')->get('app.debug') ? [
            'message' => $e->getMessage(),
            'exception' => get_class($e),
            'file' => $e->getFile(),
            'line' => $e->getLine(),
            'trace' => collect($e->getTrace())->map(function ($trace) {
                return Arr::except($trace, ['args']);
            })->all(),
        ] : [
            'message' => $this->isServiceException($e) ? $e->getMessage() : 'Server Error',
        ];
    }
1073310
protected function handleValidationException(Exception $e)
    {
        // Get the status code and build the message.
        $statusCode = 422;
        $message = $e->getMessage();
        $errorData = $e->getResponse()->getData();

        return $this->generateResponse('errors', $errorData, $statusCode, Status::FAIL, $message);
    }
225836
public function formatException(\Exception $e) {
        $entry = array();

        $entry['class'] = get_class($e);
        $entry['message'] = $e->getMessage();
        $entry['file'] = $e->getFile();
        $entry['line'] = $e->getLine();
        $entry['trace'] = $e->getTraceAsString();

        return $entry;
    }
1353735
static protected function exceptionToSlackAttach(E $e)
    {
        $fields = [ ];

        $addToField = function ($name, $value, $short = false) use (&$fields) {
            if ( ! empty( $value )) {
                $fields[] = [
                    "title" => $name,
                    "value" => $value,
                    "short" => $short
                ];
            }
        };

        $addToField("Exception", get_class($e), true);
        $addToField("Hash", ExceptionHelper::hash($e), true);
        $addToField("Http code", ExceptionHelper::statusCode($e), true);
        $addToField("Code", $e->getCode(), true);
        $addToField("File", $e->getFile(), true);
        $addToField("Line", $e->getLine(), true);
        $addToField("Request url", Request::url(), true);
        $addToField("Request method", Request::method(), true);
        $addToField("Request param", json_encode(Request::all()), true);

        return [
            "color"    => "danger",
            "title"    => $e->getMessage(),
            "fallback" => ! empty( $e->getMessage() ) ? $e->getMessage() : get_class($e),
            "fields"   => $fields,
            "text"     => $e->getTraceAsString()
        ];
    }
952938
public static function text(Exception $e)
    {
        return sprintf('%s [ %s ]: %s ~ %s [ %d ]', get_class($e), $e->getCode(), strip_tags($e->getMessage()), $e->getFile(), $e->getLine());
    }
52461
protected function getErrorResponse(Exception $e)
    {
        switch (get_class($e)) {
            case ForbiddenException::class:
                $response = $this->forbidden(
                    new ErrorBag([new Error('Forbidden', $e->getMessage())])
                );
                break;
            default:
                $response = $this->errorResponse(
                    new ErrorBag([new Error('Bad Request', 'Request could not be served.')])
                );
        }

        return $response;
    }
339723
public static function getFormattedExceptionMessage(\Exception $e)
    {
        $name = static::getExceptionNameHierarchy($e);

        list($file, $line, $stackTrace) = static::getOriginalExceptionFileAndLineNumber($e);

        $message = "{$name}: {$e->getMessage()} ({$e->getcode()})\n{$file} {$line}\n{$stackTrace}";

        return $message;
    }
453746
public function getBacktrace($exception = null)
    {
        $skipLimit = false;

        if ($exception instanceof \Exception || $exception instanceof \Throwable) {
            $backtrace = $exception->getTrace();
            foreach ($backtrace as $index => $backtraceCall) {
                unset($backtrace[$index]['args']);
            }
        } elseif (version_compare(PHP_VERSION, '5.4.0') >= 0) {
            $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $this->backtraceLimit);
            $skipLimit = true;
        } else {
            $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
        }

        if ($this->backtraceLimit > 0 && !$skipLimit) {
            $backtrace = array_slice($backtrace, 0, $this->backtraceLimit);
        }

        return $backtrace;
    }
208949
public function report(Exception $e, array $extra = [])
    {
        return $this->raygun->SendException($e, null, $extra);
    }
407601
public function exception($e)
    {
        $this->setParams(
            $e->getCode(),
            $e->getMessage(),
            $e->getFile(),
            $e->getLine(),
            $e->getTraceAsString());

        return $this->render();
    }