Jump to content

Php Exceptions


ckrudelux
 Share

Recommended Posts

Should it matter from there I catch an exception?

This works and catches the PDO exception from users

$dice = new Dice();
try {
	$dice->create('Controller');
}catch(Exception $e){

}


Try to catch the exception in the controller wont work

class Controller {
	public function __construct(Users $users){
	    try{
            $users->create('username','password');
        }catch(Exception $e){
        
        }
    }
}

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...