]> mj.ucw.cz Git - pciids.git/commitdiff
Better behavior with failure
authorMichal Vaner <vorner@ucw.cz>
Mon, 25 Aug 2008 19:36:42 +0000 (21:36 +0200)
committerMichal Vaner <vorner@ucw.cz>
Mon, 25 Aug 2008 19:36:42 +0000 (21:36 +0200)
The database is rolled back, so it should contain no locks (the
transaction has ended).

PciIds/Html/Handler.pm

index 24f33cfc053dfd80596f7c2631d3df3220be1e00..da7c10f6d583613d9daeead1c7981dd9aa99f0b1 100644 (file)
@@ -69,8 +69,15 @@ sub handler( $$ ) {
        return HTTP_BAD_REQUEST unless( defined $sub );#I do not know this action for given method
        my $auth = checkLogin( $req, $tables );#Check if logged in
        $auth->{'ssl'} = $hasSSL;
-       my $result = &{$sub}( $req, $args, $tables, $auth );#Just do the right thing
-       $tables->commit();
+       my( $result );
+       eval {
+               $result = &{$sub}( $req, $args, $tables, $auth );#Just do the right thing
+               $tables->commit();
+       };
+       if( $@ ) {
+               $tables->rollback();
+               die $@;
+       }
        return $result;
 }