0 follower

Class Yiisoft\ErrorHandler\Exception\UserException

InheritanceYiisoft\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.

Method Details

Hide inherited methods

isUserException() public static method

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;
}