Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Unable to influence \SoapFault::$code from Zend\Soap\Server::fault() #22

Open
DannyvdSluijs opened this issue Jun 27, 2016 · 2 comments

Comments

@DannyvdSluijs
Copy link

In Zend\Soap\Server::fault (https://github.com/zendframework/zf2/blob/master/library/Zend/Soap/Server.php#L1067) there is the functionality to transform an exception which is preregisterd with Zend\Soap\Server using the method registerFaultException.

Following the logic at line 1072, and $fault is an exception $code becomes the exception error code. The base class exception from PHP libraries defines \Exception::$code as an integer, which is tested in the constructor, and protected with final methods. This has the effect that \Exception::getCode() always returns an integer value.

On line 1086 this value is tested against an array of string values, therefor never making a match, causing the $code variable always being set to 'Receiver' on line 1087.

Original: zendframework/zendframework#6770

@JaisDK
Copy link

JaisDK commented Jun 7, 2018

You can work around this issue by setting the code in your exceptions construct after initializing the parent exception:

public function __construct($message = "", $code = 'Sender', Throwable $previous = null) { parent::__construct($message, 500, $previous); $this->code = $code; }

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-soap; a new issue has been opened at laminas/laminas-soap#19.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants