MindscapeHQ/raygun4php

Raygun doesn't actually report the file name and line number of the actual error, which is the most important part.

Closed this issue · 5 comments

Identical to #72

I have to do something like this to even get the data to Raygun.

$raygunClient = new RaygunClient( $transport );
            $raygunClient->SendException(
                $exception,
                ['service' => env('APP_NAME' )],
                [
                    'file' => $exception->getFile(),
                    'line' => $exception->getLine()
                ]
            );

but then it's stuffed into the "Custom" tab and isn't part of the stack trace.

Something as simple as this change to BuildStackTrace in the RayGunExceptionMessage class would put file and line into the stack trace reported to RayGun.

    private function BuildStackTrace($exception)
    {
        $traces = $exception->getTrace();
        $lines = array();

        $line = new RaygunExceptionTraceLineMessage();
        $line->FileName = $exception->getFile();
        $line->LineNumber = $exception->getLine();
        $lines[] = $line;

        foreach ($traces as $trace) {
            $lines[] = $this->BuildLine($trace);
        }

        $this->StackTrace = $lines;
    }

More info:

https://www.php.net/manual/en/exception.gettrace.php#107563

Two important points about this function which are not documented:

  1. The trace does not include the file / line at which the exception is thrown; that entry is only recorded in the top-level getFile/Line methods.
    ...

Is this project no longer supported by Mindscape HQ?

Hey @treehousetim, would you like to make a PR for your suggested modification? I'm happy to review it

Hi Robbie,

I'll be happy to do this. Give me a few days so I can make sure this approach is the best way.

Nevermind about the few days. This looks good to me.

#148