def fix_notifier_reference(resource_collection)
matching_notifier = resource_collection.find(notifying_resource)
if Array(matching_notifier).size > 1
msg = "Notification #{self} from #{notifying_resource} was created with a reference to multiple notifying "\
"resources, but can only originate from one resource. Destination resource was defined "\
"on #{resource.source_line}"
raise Chef::Exceptions::InvalidResourceReference, msg
end
self.notifying_resource = matching_notifier
rescue Chef::Exceptions::ResourceNotFound => e
err = Chef::Exceptions::ResourceNotFound.new("Resource \#{resource} is configured to receive notifications from \#{notifying_resource} with action \#{action}, \\\nbut \#{notifying_resource} cannot be found in the resource collection. \#{resource} is defined in \\\n\#{resource.source_line}\n")
err.set_backtrace(e.backtrace)
raise err
rescue Chef::Exceptions::InvalidResourceSpecification => e
err = Chef::Exceptions::InvalidResourceSpecification.new("Resource \#{resource} is configured to receive notifications from \#{notifying_resource} with action \#{action}, \\\nbut \#{notifying_resource.inspect} is not valid syntax to look up a resource in the resource collection. Notification \\\nis defined near \#{resource.source_line}\n")
err.set_backtrace(e.backtrace)
raise err
end