(#17887) Only log if message has been initialized

It's possible to run the "ensure" block without having executed either the
main or "rescue" blocks, if an Exception not derived from StandardError is
raised or when testing with Mocha expectations.

If this happens during the property.sync, this causes an immediate exit from
the main block, but the "ensure" block is still run.  The event message won't
have been initialized yet, so this then causes the logger to report:

  Puppet::Util::Log requires a message

This changes the "ensure" block to only log if it's got as far as writing a
message.

---

Resubmitting as others keep running into this problem and my responses to the ticket after my last PR being closed haven't received any response.  I don't agree that catching the network timeouts is the responsibility of this PR... that can be addressed separately by whoever it affects.