Class Yiisoft\ErrorHandler\Exception\UserException
| Inheritance | Yiisoft\ErrorHandler\Exception\UserException » Exception |
|---|
UserException is an exception and a class attribute that indicates
the exception message is safe to display to end users.
Usage:
- throw directly (
throw new UserException(...)) for explicit user-facing errors; - annotate any exception class with the
#[UserException]attribute to mark its messages as user-facing without extending this class.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| isUserException() | Yiisoft\ErrorHandler\Exception\UserException |
Method Details
| public static boolean isUserException ( Throwable $throwable ) | ||
| $throwable | Throwable | |
public static function isUserException(Throwable $throwable): bool
{
if ($throwable instanceof self) {
return true;
}
$attributes = (new ReflectionClass($throwable))->getAttributes(self::class);
return count($attributes) > 0;
}
Signup or Login in order to comment.