diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Nagios/Plugin/Config.pm | 3 | ||||
-rw-r--r-- | lib/Nagios/Plugin/Getopt.pm | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/Nagios/Plugin/Config.pm b/lib/Nagios/Plugin/Config.pm index d565973..11128dd 100644 --- a/lib/Nagios/Plugin/Config.pm +++ b/lib/Nagios/Plugin/Config.pm | |||
@@ -38,7 +38,8 @@ sub read | |||
38 | } | 38 | } |
39 | } | 39 | } |
40 | 40 | ||
41 | croak "Cannot find '$FILENAME1' or '$FILENAME2' in any standard location." unless $_[0]; | 41 | # Use die instead of croak, so we can pass a clean message downstream |
42 | die "Cannot find '$FILENAME1' or '$FILENAME2' in any standard location.\n" unless $_[0]; | ||
42 | } | 43 | } |
43 | 44 | ||
44 | $class->SUPER::read( @_ ); | 45 | $class->SUPER::read( @_ ); |
diff --git a/lib/Nagios/Plugin/Getopt.pm b/lib/Nagios/Plugin/Getopt.pm index b21dc6d..0cf8f73 100644 --- a/lib/Nagios/Plugin/Getopt.pm +++ b/lib/Nagios/Plugin/Getopt.pm | |||
@@ -242,9 +242,13 @@ sub _load_config_section | |||
242 | my ($section, $file, $flags) = @_; | 242 | my ($section, $file, $flags) = @_; |
243 | $section ||= $self->{_attr}->{plugin}; | 243 | $section ||= $self->{_attr}->{plugin}; |
244 | 244 | ||
245 | my $Config = Nagios::Plugin::Config->read($file); | 245 | my $Config; |
246 | eval { $Config = Nagios::Plugin::Config->read($file); }; | ||
247 | $self->_die($@) if ($@); #TODO: add test? | ||
246 | 248 | ||
247 | # TODO: is this check sane? Does --extra-opts=foo require a [foo] section? | 249 | # TODO: is this check sane? Does --extra-opts=foo require a [foo] section? |
250 | ## Nevertheless, if we die as UNKNOWN here we should do the same on default | ||
251 | ## file *added eval/_die above*. | ||
248 | $self->_die("Invalid section '$section' in config file '$file'") | 252 | $self->_die("Invalid section '$section' in config file '$file'") |
249 | unless exists $Config->{$section}; | 253 | unless exists $Config->{$section}; |
250 | 254 | ||