Skip to content

Commit 7ec9e5c

Browse files
committed
Add UserExceptionInterface
1 parent 59c96e6 commit 7ec9e5c

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Enh #150: Cleanup templates, remove legacy code (@vjik)
66
- New #151: Add `$traceLink` parameter to `HtmlRenderer` to allow linking to trace files (@vjik)
7+
- New #152: Add `UserExceptionInterface` to mark user exceptions (@vjik)
78

89
## 4.1.0 April 18, 2025
910

src/Exception/UserException.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
use Exception;
88

99
/**
10-
* UserException is the base class for exceptions that are meant to be shown to end users.
11-
* Such exceptions are often caused by mistakes of end users.
10+
* `UserException` represents an exception that is meant to be shown to end users.
1211
*
1312
* @final
1413
*/
15-
class UserException extends Exception
14+
class UserException extends Exception implements UserExceptionInterface
1615
{
1716
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Yiisoft\ErrorHandler\Exception;
6+
7+
use Throwable;
8+
9+
/**
10+
* Interface for exceptions that are meant to be shown to end users.
11+
* Such exceptions are often caused by mistakes of end users.
12+
*/
13+
interface UserExceptionInterface extends Throwable
14+
{
15+
}

templates/production.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
use Yiisoft\ErrorHandler\Exception\UserException;
3+
use Yiisoft\ErrorHandler\Exception\UserExceptionInterface;
44
use Yiisoft\ErrorHandler\Renderer\HtmlRenderer;
55
use Yiisoft\ErrorHandler\ThrowableRendererInterface;
66

@@ -9,7 +9,7 @@
99
* @var HtmlRenderer $this
1010
*/
1111

12-
if ($throwable instanceof UserException) {
12+
if ($throwable instanceof UserExceptionInterface) {
1313
$name = $this->getThrowableName($throwable);
1414
$message = $throwable->getMessage();
1515
} else {

0 commit comments

Comments
 (0)