puppetlabs/puppet — pull request #3063 by joshcooper (2014-09-09 21:54:39+00:00)
Title: (PUP-3222) Rescue StandardError instead of non-existent exception

Previously, the windows service provider rescued exceptions of type
Win32::Service::Error. However, FFI-based versions of win32-service (v0.8.x)
no longer raise that type of error. Instead they raise SystemCallError.

So previously, if puppet failed to manage a service, e.g. service didn't
exist, puppet would try to rescue the exception specifying a class that
was not defined:

puppet resource service foo ensure=stopped
Error: /Service[foo]: Could not evaluate: uninitialized constant Win32::Service::Error

This regression was introduced as part of PUP-1283 when we migrated from
win32-service version 0.7.x to 0.8.x.

This commit modifies the various provider methods to more broadly rescue
StandardErrors and updates the spec tests to handle the negative cases.