 <p>So in my case there has to bee a condition for errno and it has to return true.</p> <pre><code>set_error_handler( function( $errno, $errstr, $errfile, $errline, array $errcontext ) { // Cause Php does not catch stream_socket_client warnings message. if ( $errno == E_WARNING ) throw new \Exception( $errstr, $errno ); // Is necessary to handle other errors by default handler. return true; }); </code></pre>