Custom exception

class MyException extends Exception {
    // do something
}

Usage

try {
    $condition = true;
    if ($condition) {
        throw new MyException('bala');
    }
} catch (MyException $e) {
    // Handle my exception
}
Comments