Skip to content

Commit 07f2fea

Browse files
committed
Catch \Throwable instead of \Exception
`\Throwable` is the base for all errors and exceptions since PHP 7.
1 parent 2918a68 commit 07f2fea

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

src/DeferredText.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace ipl\Html;
44

5-
use Exception;
5+
use Throwable;
66

77
/**
88
* Text node where content creation is deferred until rendering
@@ -96,7 +96,7 @@ public function __toString()
9696
{
9797
try {
9898
return $this->render();
99-
} catch (Exception $e) {
99+
} catch (Throwable $e) {
100100
return Error::render($e);
101101
}
102102
}

src/Form.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
namespace ipl\Html;
44

5-
use Exception;
65
use ipl\Html\Contract\FormElement;
76
use ipl\Html\Contract\FormSubmitElement;
87
use ipl\Html\FormElement\FormElements;
98
use ipl\Stdlib\Messages;
109
use Psr\Http\Message\ServerRequestInterface;
10+
use Throwable;
1111

1212
class Form extends BaseHtmlElement
1313
{
@@ -237,7 +237,7 @@ public function handleRequest(ServerRequestInterface $request)
237237
$this->emit(Form::ON_SENT, [$this]);
238238
$this->onSuccess();
239239
$this->emitOnce(Form::ON_SUCCESS, [$this]);
240-
} catch (Exception $e) {
240+
} catch (Throwable $e) {
241241
$this->addMessage($e);
242242
$this->onError();
243243
$this->emit(Form::ON_ERROR, [$e, $this]);
@@ -363,7 +363,7 @@ protected function onError()
363363
{
364364
$errors = Html::tag('ul', ['class' => 'errors']);
365365
foreach ($this->getMessages() as $message) {
366-
if ($message instanceof Exception) {
366+
if ($message instanceof Throwable) {
367367
$message = $message->getMessage();
368368
}
369369

src/FormattedString.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace ipl\Html;
44

5-
use Exception;
65
use InvalidArgumentException;
6+
use Throwable;
77

88
use function ipl\Stdlib\get_php_type;
99

@@ -86,7 +86,7 @@ public function __toString()
8686
{
8787
try {
8888
return $this->render();
89-
} catch (Exception $e) {
89+
} catch (Throwable $e) {
9090
return Error::render($e);
9191
}
9292
}

src/HtmlDocument.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
namespace ipl\Html;
44

55
use Countable;
6-
use Exception;
76
use InvalidArgumentException;
87
use ipl\Html\Contract\Wrappable;
98
use ipl\Stdlib\Events;
109
use RuntimeException;
10+
use Throwable;
1111

1212
/**
1313
* HTML document
@@ -418,7 +418,7 @@ public function __toString()
418418
{
419419
try {
420420
return $this->render();
421-
} catch (Exception $e) {
421+
} catch (Throwable $e) {
422422
return Error::render($e);
423423
}
424424
}

src/Text.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace ipl\Html;
44

5-
use Exception;
5+
use Throwable;
66

77
/**
88
* A text node
@@ -100,7 +100,7 @@ public function __toString()
100100
{
101101
try {
102102
return $this->render();
103-
} catch (Exception $e) {
103+
} catch (Throwable $e) {
104104
return Error::render($e);
105105
}
106106
}

0 commit comments

Comments
 (0)