From a67478dd5c5915e346928193e7484983dd60c2c9 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 10 Mar 2013 15:00:03 +0000 Subject: [PATCH] Convert useless die to error+return in Plugin.pm --- Netdisco/Changes | 1 + Netdisco/lib/App/Netdisco/Web.pm | 1 + Netdisco/lib/App/Netdisco/Web/Plugin.pm | 26 ++++++++++++++++--------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Netdisco/Changes b/Netdisco/Changes index ae431ff2..b017e092 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -6,6 +6,7 @@ [BUG FIXES] + * Convert useless die to error+return in Plugin.pm * Documentation fixups 2.006000 - 2013-03-07 diff --git a/Netdisco/lib/App/Netdisco/Web.pm b/Netdisco/lib/App/Netdisco/Web.pm index 01c6eb78..b0f2c868 100644 --- a/Netdisco/lib/App/Netdisco/Web.pm +++ b/Netdisco/lib/App/Netdisco/Web.pm @@ -23,6 +23,7 @@ sub _load_web_plugins { unless $plugin =~ m/^\+/; $plugin =~ s/^\+//; + debug "loading Netdisco plugin $plugin"; eval "require $plugin"; } } diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin.pm b/Netdisco/lib/App/Netdisco/Web/Plugin.pm index c1f5172d..9c64a75d 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin.pm @@ -15,8 +15,10 @@ config->{engines}->{template_toolkit}->{INCLUDE_PATH} ||= [ setting('views') ]; register 'register_template_path' => sub { my ($self, $path) = plugin_args(@_); - die "bad template path to register_template_paths\n" - unless length $path; + if (!length $path) { + error "bad template path to register_template_paths"; + return; + } unshift @{ config->{engines}->{template_toolkit}->{INCLUDE_PATH} }, @@ -26,10 +28,13 @@ register 'register_template_path' => sub { register 'register_navbar_item' => sub { my ($self, $config) = plugin_args(@_); - die "bad config to register_navbar_item\n" - unless length $config->{id} - and length $config->{path} - and length $config->{label}; + if (!length $config->{id} + or !length $config->{path} + or !length $config->{label}) { + + error "bad config to register_navbar_item"; + return; + } foreach my $item (@{ setting('navbar_items') }) { if ($item->{id} eq $config->{id}) { @@ -45,9 +50,12 @@ sub _register_tab { my ($nav, $config) = @_; my $stash = setting("${nav}_tabs"); - die "bad config to register_${nav}_tab\n" - unless length $config->{id} - and length $config->{label}; + if (!length $config->{id} + or !length $config->{label}) { + + error "bad config to register_${nav}_item"; + return; + } foreach my $item (@{ $stash }) { if ($item->{id} eq $config->{id}) {