![]() |
Throw Exception - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Throw Exception (/showthread.php?tid=47719) |
Throw Exception - El Forum - 12-19-2011 [eluser]Unknown[/eluser] Helloo.... How to use throw exception in CodeIgnitier... this is my code...... function insert() { try { $this->db->trans_start(); $this->nim = $this->input->post('nim'); $this->nama = $this->input->post('name'); $this->db->insert('student', $this); $this->db->trans_complete(); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); throw new Exception('error'); } else { $this->db->trans_commit(); } $this->db->close; } catch (Exception $e) { log_message('debug', $e->getTrace()); } } I use the code above, but when things go wrong, why not go directly to the exception example: duplicate entry error any solution???? thanks for your help... |