获取异常的“友好”错误消息

I am trying to connect to database and if there is anything wrong I throw an exception:

class Ex_cnt extends Exception{}
class Ex_slct extends Exception{}
$server = "localhost";
$usr = "root";
$pss = "*******";
$db = "learn";
try{
        $cnt = mysqli_connect($server,$usr,$pss);
        if(!$cnt){
            throw new Ex_cnt("wrong in database details");
        }
        $dbslct = mysql_select_db($db);
        if(!$dbslct){
            throw new Ex_slct("wrong database name");
        } 
}
catch(Ex_cnt $error_cnt){
        echo $error_cnt->getMessage();
}
catch(Ex_slct $error_slct){
        echo $error_slct->getMessage();
}

the problem is that this code shows the following error

Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'root'@'localhost' (using password: YES) in D:\xampp\htdocs\learn\index.php on line 10 Unable to connect

I want it to just show

Unable to connect

You should turn off the display_errors in production environment.

ini_set('display_errors', 0);  
error_reporting(E_ALL); // While error reporting should remain at full force

Try and use:

$cnt = @mysqli_connect($server,$usr,$pss);