Skip to content

Commit

Permalink
Catch \Throwable instead of \Exception
Browse files Browse the repository at this point in the history
`\Throwable` is the base for all errors
and exceptions since PHP 7.
  • Loading branch information
nilmerg committed Jun 10, 2024
1 parent 06a73e8 commit f9d9b84
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/DeferredText.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace ipl\Html;

use Exception;
use Throwable;

/**
* Text node where content creation is deferred until rendering
Expand Down Expand Up @@ -96,7 +96,7 @@ public function __toString()
{
try {
return $this->render();
} catch (Exception $e) {
} catch (Throwable $e) {
return Error::render($e);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace ipl\Html;

use Exception;
use ipl\Html\Contract\FormElement;
use ipl\Html\Contract\FormSubmitElement;
use ipl\Html\FormElement\FormElements;
use ipl\Stdlib\Messages;
use Psr\Http\Message\ServerRequestInterface;
use Throwable;

class Form extends BaseHtmlElement
{
Expand Down Expand Up @@ -237,7 +237,7 @@ public function handleRequest(ServerRequestInterface $request)
$this->emit(Form::ON_SENT, [$this]);
$this->onSuccess();
$this->emitOnce(Form::ON_SUCCESS, [$this]);
} catch (Exception $e) {
} catch (Throwable $e) {
$this->addMessage($e);
$this->onError();
$this->emit(Form::ON_ERROR, [$e, $this]);
Expand Down Expand Up @@ -363,7 +363,7 @@ protected function onError()
{
$errors = Html::tag('ul', ['class' => 'errors']);
foreach ($this->getMessages() as $message) {
if ($message instanceof Exception) {
if ($message instanceof Throwable) {
$message = $message->getMessage();
}

Expand Down
4 changes: 2 additions & 2 deletions src/FormattedString.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace ipl\Html;

use Exception;
use InvalidArgumentException;
use Throwable;

use function ipl\Stdlib\get_php_type;

Expand Down Expand Up @@ -86,7 +86,7 @@ public function __toString()
{
try {
return $this->render();
} catch (Exception $e) {
} catch (Throwable $e) {
return Error::render($e);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/HtmlDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace ipl\Html;

use Countable;
use Exception;
use InvalidArgumentException;
use ipl\Html\Contract\Wrappable;
use ipl\Stdlib\Events;
use RuntimeException;
use Throwable;

/**
* HTML document
Expand Down Expand Up @@ -418,7 +418,7 @@ public function __toString()
{
try {
return $this->render();
} catch (Exception $e) {
} catch (Throwable $e) {
return Error::render($e);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace ipl\Html;

use Exception;
use Throwable;

/**
* A text node
Expand Down Expand Up @@ -100,7 +100,7 @@ public function __toString()
{
try {
return $this->render();
} catch (Exception $e) {
} catch (Throwable $e) {
return Error::render($e);
}
}
Expand Down

0 comments on commit f9d9b84

Please sign in to comment.