Hi there, I am trying to build some error handling into my current application. I have read around try..catch and exceptions but I am struggling to get the examples I see to work in my real world environment.
Users are allowed to enter the IP address of a second server on the network which has a soap server installed. In the case that the server has been mis-entered or is switched off, I want to try and surpress the SoapClient errors and generate my own.
So far I have got:
and:
When I call the function with:
I get a SOAP error! presumably I need to suppress the soap errors somehow but having read around the soap documentation I cannot work out how to do this. Can anyone give me some pointers please?
G
-Geeeeeeeeeeeeeeeeeeeeeeee-
Users are allowed to enter the IP address of a second server on the network which has a soap server installed. In the case that the server has been mis-entered or is switched off, I want to try and surpress the SoapClient errors and generate my own.
So far I have got:
Code:
function createSoapClient() {
if ($client = new SoapClient("[URL unfurl="true"]http://".$this->getTvIp()."/nagios-soap.php?wsdl",[/URL] array("exceptions" => 0))) {
return $client;
} else {
throw new exception('SOAP client could not be created');
return false;
}
}
and:
Code:
function makeSoapClient() {
try {
$client = $this->createSoapClient();
if ($client) {
return $client;
}
} catch (exception $e) {
die('ERROR: '.$e->getMessage());
}
}
When I call the function with:
Code:
$client = $db->makeSoapClient();
I get a SOAP error! presumably I need to suppress the soap errors somehow but having read around the soap documentation I cannot work out how to do this. Can anyone give me some pointers please?
G
-Geeeeeeeeeeeeeeeeeeeeeeee-