Merge pull request #1091 from openclassify/vedatakd

sentry fixed
This commit is contained in:
Fatih Alp 2021-06-03 15:26:13 +03:00 committed by GitHub
commit c8428dc4a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 31 deletions

View File

@ -2,34 +2,19 @@
namespace App\Exceptions; namespace App\Exceptions;
use Anomaly\Streams\Platform\Exception\ExceptionIdentifier; use Swift_TransportException;
use Exception; use Throwable;
use Illuminate\Support\Facades\Auth;
use Illuminate\Auth\AuthenticationException; use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler; use Illuminate\Foundation\Exceptions\Handler;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
use Swift_TransportException;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Throwable; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
class ExceptionHandler extends Handler class ExceptionHandler extends Handler
{ {
/**
* The exception instance.
*
* @var Exception
*/
protected $original; protected $original;
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $internalDontReport = [ protected $internalDontReport = [
\Illuminate\Auth\AuthenticationException::class, \Illuminate\Auth\AuthenticationException::class,
\Illuminate\Auth\Access\AuthorizationException::class, \Illuminate\Auth\Access\AuthorizationException::class,
@ -39,14 +24,14 @@ class ExceptionHandler extends Handler
\Illuminate\Validation\ValidationException::class, \Illuminate\Validation\ValidationException::class,
]; ];
protected function prepareException(Exception $e) protected function prepareException(Throwable $e)
{ {
$this->original = $e; $this->original = $e;
return parent::prepareException($e); // TODO: Change the autogenerated stub return parent::prepareException($e); // TODO: Change the autogenerated stub
} }
public function render($request, Exception $e) public function render($request, Throwable $e)
{ {
if ($e instanceof AuthenticationException) { if ($e instanceof AuthenticationException) {
return $this->unauthenticated($request, $e); return $this->unauthenticated($request, $e);
@ -67,10 +52,10 @@ class ExceptionHandler extends Handler
$summary = $e->getMessage(); $summary = $e->getMessage();
$headers = $e->getHeaders(); $headers = $e->getHeaders();
$code = $e->getStatusCode(); $code = $e->getStatusCode();
$name = trans("streams::error.{$code}.name"); $name = trans("streams::error.{$code}.name");
$message = trans("streams::error.{$code}.message"); $message = trans("streams::error.{$code}.message");
$id = $this->container->make(ExceptionIdentifier::class)->identify($this->original); $id = $this->container->make(ExceptionIdentifier::class)->identify($this->original);
if (view()->exists($view = "streams::errors/{$code}")) { if (view()->exists($view = "streams::errors/{$code}")) {
return response()->view($view, compact('id', 'code', 'name', 'message', 'summary'), $code, $headers); return response()->view($view, compact('id', 'code', 'name', 'message', 'summary'), $code, $headers);
@ -84,8 +69,7 @@ class ExceptionHandler extends Handler
); );
} }
public function report(Throwable $e)
public function report(Exception $e)
{ {
if (app()->bound('sentry') if (app()->bound('sentry')
&& $this->shouldReport($e) && $this->shouldReport($e)
@ -107,9 +91,9 @@ class ExceptionHandler extends Handler
try { try {
return array_filter( return array_filter(
[ [
'user' => Auth::id(), 'user' => Auth::id(),
'email' => Auth::user() ? Auth::user()->email : null, 'email' => Auth::user() ? Auth::user()->email : null,
'url' => request() ? request()->fullUrl() : null, 'url' => request() ? request()->fullUrl() : null,
'identifier' => $this->container->make(ExceptionIdentifier::class)->identify($this->original), 'identifier' => $this->container->make(ExceptionIdentifier::class)->identify($this->original),
] ]
); );

View File

@ -32,7 +32,7 @@ return [
*/ */
'bindings' => [ 'bindings' => [
// 'Anomaly\Streams\Platform\Exception\ExceptionHandler' => ExceptionHandler::class 'Anomaly\Streams\Platform\Exception\ExceptionHandler' => ExceptionHandler::class
], ],
/* /*