Handler.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace App\Exceptions;
  3. use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
  4. use Illuminate\Support\Facades\Http;
  5. use Throwable;
  6. class Handler extends ExceptionHandler
  7. {
  8. /**
  9. * A list of the exception types that are not reported.
  10. *
  11. * @var array
  12. */
  13. protected $dontReport = [
  14. //
  15. ];
  16. /**
  17. * A list of the inputs that are never flashed for validation exceptions.
  18. *
  19. * @var array
  20. */
  21. protected $dontFlash = [
  22. 'password',
  23. 'password_confirmation',
  24. ];
  25. /**
  26. * Register the exception handling callbacks for the application.
  27. *
  28. * @return void
  29. */
  30. public function register()
  31. {
  32. $this->reportable(function (Throwable $e) {
  33. try {
  34. if(!$e->getMessage()){
  35. return;
  36. }
  37. if(strtolower($e->getMessage()) == 'not found'){
  38. //ignore
  39. return;
  40. }
  41. $url = config('stag.backendUrl') . '/dev/reportPhpError';
  42. $headers['secret'] = 'superman';
  43. Http::asForm()
  44. ->withHeaders($headers)
  45. ->post($url, [
  46. 'data'=>'LHR: '.$e->getMessage().' URL: '.url()->current(),
  47. 'secret' => 'superman'
  48. ])
  49. ->json();
  50. }catch(\Exception $e){
  51. //do nothing
  52. }
  53. });
  54. }
  55. }