How to catch exceptions?

Hi,
i’m writing my custom scheduler function where a PDO connection is made to retrieve some information.

I’ve create, like usual, a try and catch block in order to catch exceptions but it won’t works.

Any suggestion on this?

Regards

Even though this is a PHP question, we can try helping… but we would have to see the code. Often the problem is just a small detail or even punctuation… it is only possible to see by reading the exact code.

Yes…sure

Just for example…a simple pdo connection to external database:

function importHubs(){
$GLOBALS[‘log’]->FATAL(’************************ Hubs Import START ***************’);
$GLOBALS[‘log’]->FATAL('
Connecting to DATAWAREHOUSE ’);
try{
$dsn = “mysql:host=.;dbname=”;
$options = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
$PDOconn = new PDO($dsn, “username” , “password”, $options);
} catch (PDOException $e){
$GLOBALS[‘log’]->FATAL('
OPS !!! NOT CONNECTED to DATAWAREHOUSE *************’);
$GLOBALS[‘log’]->FATAL($e->getMessage());
return false;
}

    //$PDOconn->query("bla bla bla");
    $GLOBALS['log']->FATAL('***************  WHAO !!!!! CONNECTED to DATAWAREHOUSE *************');
    return true;
}

This script for example does not generate any exception.

Using it outside SuiteCRM the exception was captured…

Any hint?

Regards

Sorry…the example above seems to work.

Maybe some typo in my previous code.

This can be considered as solved.

really sorry