No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

41 líneas
1011B

  1. <?php
  2. namespace Framework\Support;
  3. use Framework\Validation\Exception\ValidationException;
  4. use Throwable;
  5. use Whoops\Handler\PrettyPageHandler;
  6. use Whoops\Run;
  7. class ExceptionHandler
  8. {
  9. public function showThrowable(Throwable $throwable)
  10. {
  11. if ($throwable instanceof ValidationException) {
  12. return $this->showValidationException($throwable);
  13. }
  14. if (isset($_ENV['APP_ENV']) && $_ENV['APP_ENV'] === 'dev') {
  15. $this->showFriendlyThrowable($throwable);
  16. }
  17. }
  18. public function showValidationException(ValidationException $exception)
  19. {
  20. if ($session = session()) {
  21. $session->put($exception->getSessionName(), $exception->getErrors());
  22. }
  23. return redirect(env('HTTP_REFERER'));
  24. }
  25. public function showFriendlyThrowable(Throwable $throwable)
  26. {
  27. $whoops = new Run();
  28. $whoops->pushHandler(new PrettyPageHandler());
  29. $whoops->register();
  30. throw $throwable;
  31. }
  32. }

Powered by TurnKey Linux.