-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an optional third parameter to redisget() to specify a default value #207
Conversation
ebd2a73
to
ab7f5cc
Compare
@petems I got the acceptance tests this time :) |
@ghoneycutt Awesome stuff! 😄 I might ask you to rebase as I was doing some work to update the function docs to work with puppet-strings (see #208), but overall looks good |
No problem, I'll rebase once #208 gets merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a little refactoring around the core defaulting logic
raise(Puppet::ParseError, "redisget(): Wrong argument type given (#{key.class} for String) for arg1 (key)") if key.is_a?(String) == false | ||
raise(Puppet::ParseError, "redisget(): Wrong argument type given (#{url.class} for String) for arg2 (url)") if url.is_a?(String) == false | ||
|
||
begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic looks a little confusing to me, could we clean this up somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly something like changing k
to returned_value
? And is there a way to break out the nesting? Not sure if there's something better it just looks a little confusing IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed the variable name and added the exception message to the output as requested
else | ||
k | ||
end | ||
rescue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to pick which error to rescue from here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like
rescue Exception => e
if default
debug "Connection to redis failed with #{e}"
default
else
raise(Puppet::Error, "Connection to redis server failed - #{e}")
end
end
Gives a little more detail for both the happy and sad paths
ab7f5cc
to
a34ed57
Compare
Merged in #209 |
No description provided.