[carton] 28/472: Properly display errors
Lucas Kanashiro
kanashiro-guest at moszumanska.debian.org
Fri Jul 24 00:38:28 UTC 2015
This is an automated email from the git hooks/post-receive script.
kanashiro-guest pushed a commit to branch master
in repository carton.
commit b0ef548e70348e5dc6ddeef22d16b47df18635f4
Author: Tatsuhiko Miyagawa <miyagawa at bulknews.net>
Date: Sun Jun 26 00:36:19 2011 -0700
Properly display errors
---
Makefile.PL | 1 +
lib/Carton/CLI.pm | 18 +++++++++++++++---
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/Makefile.PL b/Makefile.PL
index 85833e5..98dce8a 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -10,6 +10,7 @@ requires 'JSON';
requires 'App::cpanminus', 1.5000;
requires 'Term::ANSIColor';
requires 'Module::Metadata', 1.000003;
+requires 'Try::Tiny';
install_script 'bin/carton';
diff --git a/lib/Carton/CLI.pm b/lib/Carton/CLI.pm
index 4a77bc4..1fb2ed6 100644
--- a/lib/Carton/CLI.pm
+++ b/lib/Carton/CLI.pm
@@ -11,6 +11,7 @@ use Getopt::Long;
use Term::ANSIColor qw(colored);
use Carton::Tree;
+use Try::Tiny;
our $Colors = {
SUCCESS => 'green',
@@ -179,7 +180,6 @@ sub cmd_show {
my $lock = $self->lock_data
or $self->error("Can't find carton.lock: Run `carton install` to rebuild the spec file.\n");
-
if ($tree_mode) {
$self->carton->walk_down_tree($lock, sub {
my($module, $depth) = @_;
@@ -221,9 +221,21 @@ sub cmd_exec {
sub lock_data {
my $self = shift;
- $self->{lock} || do {
- Carton::Util::parse_json($self->lock_file);
+
+ return $self->{lock} if $self->{lock};
+
+ try {
+ my $lock = Carton::Util::parse_json($self->lock_file);
+ $self->{lock} = $lock;
+ } catch {
+ if (/No such file/) {
+ $self->error("Can't locate carton.lock\n");
+ } else {
+ $self->error("Can't parse carton.lock: $_\n");
+ }
};
+
+ return $self->{lock};
}
sub lock_file {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/carton.git
More information about the Pkg-perl-cvs-commits
mailing list