google-measurement-php-client
google-measurement-php-client copied to clipboard
When Internet is not available socket_connect throws a 'Host name lookup failure' PHP error
In no Internet available condition, the socket_connect call in Socket.php createConnection function throws the following error:
A PHP Error was encountered Servetity: Warning
Message: socket_connect(): Host loockup failed [-10002]: Host name lookup failure Filename: Adapter/Socket.php
Line Number: 32
Backtrace: [...]
that ignoring the possible false return, and any exception throwing and try&catch.
Is there any way to avoid that error message in that specific call?
Thanks @daN4cat! I personally think it is better to throw an exception and let the consumer decide how to handle this exception. But it would be better to throw an generic connection exception than the socket specific error. What is you opinion on this?
Ideally this should be captured at the level of function call and then throw the already existing exception, I believe we are saying the same.
The current way bypasses what is already in place and doesn't allow any sensible handling (e.g. switch off the GA feature, retry later, simple error logging) at top function caller level.