Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
treehousetim opened this issue Apr 26, 2022 · 5 comments · Fixed by #148

Comments

@treehousetim
Copy link
Contributor

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;
    }
@treehousetim
Copy link
Contributor Author

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.
    ...

@treehousetim
Copy link
Contributor Author

Is this project no longer supported by Mindscape HQ?

@robbieaverill
Copy link
Contributor

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

@treehousetim
Copy link
Contributor Author

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.

@treehousetim
Copy link
Contributor Author

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

#148

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants