[carton] 436/472: remove Exception::Class

Lucas Kanashiro kanashiro-guest at moszumanska.debian.org
Fri Jul 24 00:39:34 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 d0e650402d23bf1e9e2be68b3fe38b55419e3c4b
Author: Tatsuhiko Miyagawa <miyagawa at bulknews.net>
Date:   Sun Apr 19 16:56:20 2015 +0200

    remove Exception::Class
---
 cpanfile            |  1 -
 lib/Carton/Error.pm | 46 ++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/cpanfile b/cpanfile
index b7ff9d7..346c443 100644
--- a/cpanfile
+++ b/cpanfile
@@ -10,7 +10,6 @@ requires 'Module::CPANfile', 0.9031;
 
 requires 'Try::Tiny', 0.09;
 requires 'parent', 0.223;
-requires 'Exception::Class', 1.32;
 requires 'Getopt::Long', 2.39;
 requires 'Moo', 1.002;
 requires 'Path::Tiny', 0.033;
diff --git a/lib/Carton/Error.pm b/lib/Carton/Error.pm
index 7c8074f..b469eac 100644
--- a/lib/Carton/Error.pm
+++ b/lib/Carton/Error.pm
@@ -1,12 +1,42 @@
 package Carton::Error;
 use strict;
-use Exception::Class (
-    'Carton::Error',
-    'Carton::Error::CommandNotFound' => { isa => 'Carton::Error' },
-    'Carton::Error::CommandExit' => { isa => 'Carton::Error', fields => [ 'code' ] },
-    'Carton::Error::CPANfileNotFound' => { isa => 'Carton::Error' },
-    'Carton::Error::SnapshotParseError' => { isa => 'Carton::Error', fields => [ 'path' ] },
-    'Carton::Error::SnapshotNotFound' => { isa => 'Carton::Error', fields => [ 'path' ] },
-);
+use overload '""' => sub { $_[0]->error };
+use Carp;
+
+sub throw {
+    my($class, @args) = @_;
+    die $class->new(@args);
+}
+
+sub rethrow {
+    die $_[0];
+}
+
+sub new {
+    my($class, %args) = @_;
+    bless \%args, $class;
+}
+
+sub error {
+    $_[0]->{error} || ref $_[0];
+}
+
+package Carton::Error::CommandNotFound;
+use parent 'Carton::Error';
+
+package Carton::Error::CommandExit;
+use parent 'Carton::Error';
+sub code { $_[0]->{code} }
+
+package Carton::Error::CPANfileNotFound;
+use parent 'Carton::Error';
+
+package Carton::Error::SnapshotParseError;
+use parent 'Carton::Error';
+sub path { $_[0]->{path} }
+
+package Carton::Error::SnapshotNotFound;
+use parent 'Carton::Error';
+sub path { $_[0]->{path} }
 
 1;

-- 
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