[libcatmandu-perl] 58/85: Making some more sense out of the command line error messages

Jonas Smedegaard dr at jones.dk
Tue May 20 09:56:19 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.91
in repository libcatmandu-perl.

commit 53df033e241b748215b56a1695666b73194d15ed
Author: Patrick Hochstenbach <patrick.hochstenbach at ugent.be>
Date:   Fri May 16 22:16:48 2014 +0200

    Making some more sense out of the command line error messages
---
 lib/Catmandu/CLI.pm | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/lib/Catmandu/CLI.pm b/lib/Catmandu/CLI.pm
index 3f0365a..237dace 100644
--- a/lib/Catmandu/CLI.pm
+++ b/lib/Catmandu/CLI.pm
@@ -45,7 +45,21 @@ sub run {
     $self->set_global_options($global_opts);
     my ($cmd, $opts, @args) = $self->prepare_command(@$argv);
 
-    $self->execute_command($cmd, $opts, @args);
+    eval {
+        $self->execute_command($cmd, $opts, @args);
+    };
+    if ($@) {
+        if ($@ =~ /^Can't locate Catmandu\/Importer/ && $ARGV[1] eq 'help') {
+            print STDERR "You probably mean:\n\n\t$0 $ARGV[1] $ARGV[0]\n";
+        }
+        elsif ($@ =~ /Can't locate Catmandu\/(Importer|Exporter|Store)\/([^\.]+)/) {
+            print STDERR "Can't find:\n\n\tCatmandu::$1\::$2\n\nin your installation. Or a\n\n\t$2\n\nin your catmandu.yml\n";
+        }
+        else {
+            die $@;
+        }
+    }
+
 }
 
 1;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-perl.git



More information about the Pkg-perl-cvs-commits mailing list