Hey @cat24max,
As @joecme stated it is best to add the shouldReport
check since in newer Laravel versions the auth middleware causes a exception to be thrown which redirects the user to the login page, however looking at the examples in the repo we are not currently doing that assuming that is were you got the code for the render method.
private $sentryID;
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
if (app()->bound('sentry') && $this->shouldReport($exception)) {
return response()->view('errors.500', [
'sentryID' => $this->sentryID,
], 500);
}
return parent::render($request, $exception);
}
Or maybe even share the SentryID to the view and let the app decide what to render.
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
if(app()->bound('sentry') && $this->shouldReport($exception)) {
\View::share('sentryID', $this->sentryID);
}
return parent::render($request, $exception);
}
This would ofcourse only work then the report
function looks like this
private $sentryID;
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
if (app()->bound('sentry') && $this->shouldReport($e)) {
$this->sentryID = app('sentry')->captureException($e);
}
parent::report($e);
}
A last option would be to simple not change the render
method at all and use the Sentry
facade to get the last event id directly in the view like this:
<p>
If you see people running around trying to find out what happend
present them with this ID: {{ Sentry::getLastEventID() }}.
They will know what to do with it!
</p>
Let me know if this helps
If so I will try to make this more clear in the examples and readme of sentry-laravel
.