I'm getting a MultiReasonException
thrown during a DNS lookup as part of a AMP Socket connect call. The actual exception thrown is an NX domain, which is fine - the lookup is for a host which is down currently. The problem is I cannot catch and handle the exception - it ends up at the loop level where I am able to catch it, but it's no use at that point.
I tried to reproduce in a simple test script for posting here, but it works correctly if I just do:
Loop::run(function(){
$res = yield \Amp\Dns\resolve("tp-link-hs110-5");
var_dump($res);
});
and wrap it in a try catch I'm able to catch the DNS exception - it doesn't even throw a MultiReasonException
. I think this is something to do with the fact my actual application has a lot more going on "concurrently" which means the loop actually goes off and does other stuff while waiting for the DNS request to fail ("defers" the dns lookup coroutine). This appears to cause the exception to be thrown wrapped in a MultiReasonException
for some reason (there is only 1 exception listed in the Mutli in xdebug). What's more, the MultiReasonException
is not thrown into my coroutine where the connect call was made, it just ends up being thrown into the Loop::run
call - and this is the real problem. I cannot handle the exception here, since it's not in the calling context and could be from anywhere in the code.
Can anyone help shed any light on this, or even point me in the right direction to pin this down a little more? I'm all out of ideas. Trying to trace this thing through a massive stack full of Coroutines and Placeholder functions is a nightmare. How on Earth do you debug such things through the AMP stack?