I've just read some articles about exceptions and the most part of the examples do this kind of stuff:
try{
conn.close();
} catch(SQLException ex){
logger.error("Cannot close connection");
throw new RuntimeException(ex);
}
While I'm used to do this:
try
{
$this->pdo = new PDO($dbInfo[0], $dbInfo[1], $dbInfo[2]);
$this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
$this->exceptionHandler->displayException($e);
}
As you can see, I use a class to handle exception instead of re-throwing it.
For instance, if a class A uses a instance B which uses a instance C which can throws an exception, I will directly handle it in the class B and not re-trowing it to the class A.
However, according to the first example, it seems that the guy just re-throws all the sub classes exceptions to a main class (like A by using my example).
Is my method bad?