Redis lookup with a default value
First of all NEVER rescue ExceptionError. If you want a to rescue from any runtime exception, just omit exception class, otherwise you might catch SignalException which happens upon ruby process received some signal (e.g. SIGTERM) and instead of behave correctly you will silently skip that.

So, your rescue part should look actually like this:

begin
  # ...
rescue SocketError, Redis::CannotConnectError =&gt; e
  raise Puppet::Error, "connection to redis server failed - #{e}" unless default
  debug "Connection to redis failed with #{e} - Returning default value of #{default}"
  default
end


Now your main block can be also improved:

begin
  Redis.new(:url =&gt; url).get(key) || default
rescue
  # ...
end


Notice that redis returns either String or Nil, e.g.:

Redis.current.set(:x, 123)
Redis.current.get(:x) # =&gt; "123"

Redis.current.set(:x, false)
Redis.current.get(:x) # =&gt; "false"


So, summing all above together, you can form that into a method:

def redis_get(key, url:, default: nil)
  Redis.new(:url =&gt; url).get(key) || default
rescue SocketError, Redis::CannotConnectError =&gt; e
  raise Puppet::Error, "connection to redis server failed - #{e}" unless default
  debug "Connection to redis failed with #{e}; Return default: #{default}"
  default
end