(PUP-2298) add resource lifecycle method Puppet::Type#pre_run_check

In order to deprecate the builtin defined function (which is often abused
to work around resource duplication among modules) it is desirable to
add resource constraints to the language. An easy approach to allowing such
constraints to work is to add them as a special resource type that does not
take effect during the transaction, but fails the whole catalog in case of
validation failure.

To make this possible, add a new method #pre_run_check to the Type base class
for overriding in appropriate resource types (such as constraint).

The semantics is simply
- raise nothing if the pre-run check is succesful
- raise a Puppet::Error otherwise

The check is performed during evaluation of the transaction, just before
the catalog is applied. The generating of additional resources should be
complete when this is done (because the hook is meant to be able to
check the whole catalog for consistency).
(PUP-2298) protect transaction spec test against new exceptions

The new perform_pre_run_checks method in the transaction loops over
all resources in the catalog. This is prone to failures if any nil references
end up in the catalog. This can happen during the addition of resources
to the catalog under test conditions, because the mock resources are not
sufficiently contained.

To work around this effect, stub the very #container_of method in the mock
catalog so that all resources will have an apparent container.
(PUP-2298) Use resource specific log_exception

Previously, we were logging the exception using `Puppet.err` and
passing in the resource reference in the message.

This commit changes it to use the log_exception method mixed into the
resource (Puppet::Type) so that we get resource-specific error
messages.

    Error: /Stage[main]/Main/Notify[hello]: something is not right
Merge branch 'pr/2549'

* pr/2549:
  (PUP-2298) Use resource specific log_exception
  (PUP-2298) protect transaction spec test against new exceptions
  (PUP-2298) add resource lifecycle method Puppet::Type#pre_run_check

Closes GH-2549