cakephp: SOAP Client exception cannot be caught
This is a (multiple allowed):
- bug
- enhancement
- feature-discussion (RFC)
- CakePHP Version: CakePHP Version: 3.2.3
- Platform and Target: Apache 2.4.12 (Win32) PHP 5.6.11 MySQL 5.6.25, GET
What you did
I tried to call a SOAP API as a client and catch a fatal error, caused by missing WSDL file or network connectivity issues.
try {
$soap_client = new SoapClient($wsdl_file, ['exceptions' => true]);
}
catch (SoapFault $e) {
echo 'a soap error occurred<br>';
}
echo 'I can still do stuff after the error<br>';
The code above works in vanilla PHP, but not in CakePHP.
Expected Behavior
I should be able to catch the exception
Actual Behavior
The exception is not caught
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (13 by maintainers)
Commits related to this issue
- Bugfix for Error: Datasource class could not be found Also see https://github.com/cakephp/cakephp/issues/8501 — committed to Oefenweb/cakephp-uni-login-webservice by tersmitten 8 years ago
@josegonzalez I came up with a workaround.
Edit: use trigger_error() and keep the exception message.
I just want to add I came across this problem and the suggested solution wasn’t working for me what did work was catching \SoapFault with the backslash: