A custom exception class gives a domain-specific name to a failure.

Custom Exception

custom_exception.php
<?php
class LimitExceeded extends Exception
{
}

$count = ;

try {
    if ($count > 5) {
        throw new LimitExceeded("too many");
    }

    $status = "within_limit";
} catch (LimitExceeded $error) {
    $status = "limit_error";
}

echo "count=" . $count . "\n";
echo "status=" . $status . "\n";
<?php
class LimitExceeded extends Exception
{
}

$count = ;

try {
    if ($count > 5) {
        throw new LimitExceeded("too many");
    }

    $status = "within_limit";
} catch (LimitExceeded $error) {
    $status = "limit_error";
}

echo "count=" . $count . "\n";
echo "status=" . $status . "\n";
<?php
class LimitExceeded extends Exception
{
}

$count = ;

try {
    if ($count > 5) {
        throw new LimitExceeded("too many");
    }

    $status = "within_limit";
} catch (LimitExceeded $error) {
    $status = "limit_error";
}

echo "count=" . $count . "\n";
echo "status=" . $status . "\n";
domain error The class name can be more useful than a generic message when selecting recovery.