I was trying to send a document to a printer. This is the code I used:
try
{
$fp = pfsockopen($ip, $port,$errno,$errstr,30);
fputs($fp, $sContent);
fclose($fp);
$this->session->set_flashdata('message_header','Document verstuurd');
$this->session->set_flashdata('message_status','info');
$this->session->set_flashdata('message', 'Uw document is verstuurd naar de printer');
$this->redirect('/goods_receipt/history');
}
catch (Exception $e)
{
$this->session->set_flashdata('message',$e->getMessage());
$this->session->set_flashdata('message_status','danger');
$this->session->set_flashdata('message_header', 'Er is een fout opgetreden');
$this->redirect('/goods_receipt/history');
}
Silly old me forgot to set the IP address. I would have expected an exception and then the flash message to be shown, but instead my customer saw this:
What am I doing wrong?
p.s.: Please note I don't need any help finding why the error was thrown. I've worked that out. I just need to understand why the exception handler got ignored so that next time the socket can't be opened, a rather less scary screen gets shown.