php - How to throw custom exceptions in codeigniter? -
i want know how throw custom exception messages in codeigniter when situations following happen:
- connection database failed reason(i intentionally gave non-existent database name in application/config/database.php file test , tried try-catch on $this->db->get() did not work. codeigniter gave own error message)
2.a method fails execute. tried ::
try { $this->model_name->myfunc();//myfunc non-existent method other reason failure should handled using custom message }catch(exception $e) { echo "method failed run"; }
this did not worked too
there many kind of exceptions, maybe you'll need catch example mysqli_sql_exception
try{ // code connect db }catch(mysqli_sql_exception $e) { return 'custom message'; }