]> gitweb.fluxo.info Git - puppet-stdlib.git/commit
(#12357) Add ability to display an error message from validate_re
authorJeff McCune <jeff@puppetlabs.com>
Wed, 7 Mar 2012 23:01:11 +0000 (15:01 -0800)
committerJeff McCune <jeff@puppetlabs.com>
Wed, 7 Mar 2012 23:33:27 +0000 (15:33 -0800)
commit41b07232e464f25403a8f9c786ec0061bf6dc40e
tree44dccf99e8f7ebbcf3d8a061ee3a467689385d94
parent898ff80fa762dbbe52f50b872dd1bf3b04c254c9
(#12357) Add ability to display an error message from validate_re

I've seen a number of times the following error displayed to the end
user:

    validate_re(): "" does not match "^true$|^false$" at /p/t/f.pp:40

This is an absolutely horrific error message.  I'm to blame for it.
Users stumble over this quite often and they shouldn't have to go read
the code to sort out what's happening.

This patch makes an effort to fix the problem by adding a third,
optional, argument to validate_re().  This third argument will be the
message thrown back in the exception which will be displayed to the end
user.

This sets the stage for nicer error messages coming from modules we
write.

This patch is backwards compatible but is a new feature.
lib/puppet/parser/functions/validate_re.rb
spec/unit/puppet/parser/functions/validate_re_spec.rb [new file with mode: 0644]