title: Puppet have a defined resource fail if a variable is set to undef
body: <p>I am writing a puppet defined type as follows:</p>
  
  <pre><code>  1 #--------------------------------------------------#
    2 #-------------------WindowsLog---------------------#
    3 #--------------------------------------------------#
    4 #           Type to set up a windows log           #
    5 #--------------------------------------------------#
    6
    7 define windows_log($size = '25MB', $overflowAction = 'OverwriteAsNeeded', $logName = $title)
    8 {
    9
   10     #Microsoft is stupid. Get-WinEvent has different names for logmode than limit-eventlog.
   11     #The following selector (basuically a ternary operator) should fix that
   12     $overflowWinEventName = $overflowAction ? {
   13         OverwriteAsNeeded   =&gt; "Circular",
   14         OverwriteOlder      =&gt; "AutoBackup",
   15         DoNotOverwrite      =&gt; "Retain",
   16         default             =&gt; undef,
   17     }
   18
   19     if($overflowWinEventName == undef)
   20     {
   21         fail("${$overflowAction} is not a valid overflow action")
   22     }
   23     else{
   24         exec { "Set maximum log size for ${logName}":
   25             provider =&gt; powershell,
   26             command  =&gt; "Limit-EventLog -LogName ${logName} -MaximumSize ${size} -OverflowAction ${overflowAction}",
   27             unless   =&gt; "\$log = Get-WinEvent -ListLog ${logName}; if(\$log.MaximumSizeInBytes -eq ${size} -and \$log.LogMode -eq '${overflowWinEventName}'){exit 0}else{exit 1}",
   28         }
   29     }
   30 }
  </code></pre>
  
  <p>However the method 'fail' does not have the effect I want, and none of the methods listed at <a href="http://docs.puppetlabs.com/references/latest/function.html" rel="nofollow">http://docs.puppetlabs.com/references/latest/function.html</a> seem to be right either.</p>
  
  <p>Basically I am trying to get puppet to throw an error for this specific resource only, stop applying it, and then continue applying everything else. Fail throws a parser error which kills everything, and the other methods (warn, error, etc) seem to have no effect on the agent.</p>
  
  <p>Any help would be greatly appreciated! I may have just stupidly overlooked something.</p>