thephpleague / statsd

A library for working with StatsD
MIT License
351 stars 56 forks source link

Propagate ConnectionException message via trigger_error() #57

Closed filakhtov closed 2 years ago

filakhtov commented 4 years ago

What & Why?

As it presently stands, the ConnectionException is thrown when opening a socket fails and contains the system-level error code and message. This information, however, is only accessible if the throwConnectionExceptions flag is set and the original exception is propagated to the consumer. If the exception is disabled, then a user warning will be created using the trigger_error() function, which unfortunately does not carry an information from the exception, leading to inability to properly debug connection issues. With this change the original exception message will be appended to the produced warning.

Before

StatsD server connection failed (udp://hostdoesnotexiststalleverlol.stupidtld:8125)

After

StatsD server connection failed (udp://hostdoesnotexiststalleverlol.stupidtld:8125): (0) php_network_getaddresses: getaddrinfo failed: Name or service not known
serroba commented 4 years ago

It would be nice to have this added @marcqualie 🙏 🙇