[Bast-commits] r3511 - in trunk/DBIx-Class: . lib/DBIx/Class t

blblack at dev.catalyst.perl.org blblack at dev.catalyst.perl.org
Tue Jun 19 01:21:56 GMT 2007


Author: blblack
Date: 2007-06-19 01:21:56 +0100 (Tue, 19 Jun 2007)
New Revision: 3511

Modified:
   trunk/DBIx-Class/Changes
   trunk/DBIx-Class/lib/DBIx/Class/Exception.pm
   trunk/DBIx-Class/t/34exception_action.t
Log:
exception rethrow method from LTJake

Modified: trunk/DBIx-Class/Changes
===================================================================
--- trunk/DBIx-Class/Changes	2007-06-18 17:06:36 UTC (rev 3510)
+++ trunk/DBIx-Class/Changes	2007-06-19 00:21:56 UTC (rev 3511)
@@ -1,5 +1,7 @@
 Revision history for DBIx::Class
 
+        - new method "rethrow" for our exception objects
+
 0.08001 2007-06-17 21:21:02
         - Cleaned up on_connect handling for versioned
         - removed DateTime use line from multi_create test

Modified: trunk/DBIx-Class/lib/DBIx/Class/Exception.pm
===================================================================
--- trunk/DBIx-Class/lib/DBIx/Class/Exception.pm	2007-06-18 17:06:36 UTC (rev 3510)
+++ trunk/DBIx-Class/lib/DBIx/Class/Exception.pm	2007-06-19 00:21:56 UTC (rev 3511)
@@ -68,6 +68,17 @@
     die $self;
 }
 
+=head2 rethrow
+
+This method provides some syntactic sugar in order to
+re-throw exceptions.
+
+=cut
+
+sub rethrow {
+    die shift;
+}
+
 =head1 AUTHORS
 
 Brandon L. Black <blblack at gmail.com>

Modified: trunk/DBIx-Class/t/34exception_action.t
===================================================================
--- trunk/DBIx-Class/t/34exception_action.t	2007-06-18 17:06:36 UTC (rev 3510)
+++ trunk/DBIx-Class/t/34exception_action.t	2007-06-19 00:21:56 UTC (rev 3511)
@@ -5,7 +5,7 @@
 use lib qw(t/lib);
 use DBICTest;
 
-plan tests => 6;
+plan tests => 8;
 
 # Set up the "usual" sqlite for DBICTest
 my $schema = DBICTest->init_schema;
@@ -19,8 +19,14 @@
 
 # Basic check, normal exception
 eval { throwex };
+my $e = $@; # like() seems to stringify $@
 like($@, $ex_regex);
 
+# Re-throw the exception with rethrow()
+eval { $e->rethrow };
+isa_ok( $@, 'DBIx::Class::Exception' );
+like($@, $ex_regex);
+
 # Now lets rethrow via exception_action
 $schema->exception_action(sub { die @_ });
 eval { throwex };




More information about the Bast-commits mailing list