PDO - When to use try/catch block and when not to?

Posted in CategoryGeneral Discussion
  • Terry Ogbemudia 4 months ago
    Yeah different people will always have different opinions, generally you should use a try catch block if you use anything that can throw an exception for example when using PDO you expect a PDO exception so you should use a try catch block. 


    It think it’s generally good to use it, even when using a logger which in itself doesn’t catch an exception 

  • Hder 5 months ago

    Concerning using PDO/MySQL procedures, I have read some people saying do not use try/catch blocks every where but rather use the error logging features of the database system, others say use it everywhere...?  Can you give your comments on when to use try/catch and when not to.  Does it matter if you are in  a) the testing environment or b) the production environment?


    Thanks, Henry.

Please login or register to leave a response.