SOAP ERROR shows NetteModule\ErrorPresenter (HTTP 500) instead my custom ErrorPresenter

8 months ago

bohacf
Backer | 5
+
0
-

Hi,
I have problem with SOAP Error (error).
A HTTP 500 error occurs when the destination server is unavailable, a try..catch block is ignored.
My ErrorPresenter is also skipped (why?).

config.neon

application:
    catchExceptions: yes
    errorPresenter: Error

PHP code:

    public function actionTestSoap() {
// test 1 - displays my ErrorPresenter
//            throw new \Exception('Displays my ErrorPresenter as expected');
        try {
// test 2 - displays JSON
//            throw new \Exception('Displays JSON');

            $soap = new \SoapClient("http://localhost", [
                'location' => "fake/test/soap/",
                'keep_alive' => false,
                'exceptions' => true,
            ]);
            $soap->FakeMethod();
            $this->sendJson('OK');
        } catch (\SoapFault $fault) {
            $msg = $fault->getMessage();
            $this->sendJson("SoapFault: $msg");

        } catch (\Exception $exc) {
            $msg = $exc->getMessage();
            $this->sendJson("Exception: $msg");
        }
    }

In exception.log is “Fatal Error: SOAP-ERROR: Parsing WSDL: Couldn't load from ‘http://localhost’”.

Do you have any idea, how to catch this specific error or how to show my ErrorPresenter?
Why NetteModule\ErrorPresenter is displayed instead of my, in this case?

Franky