From: Michal Vaner Date: Mon, 25 Aug 2008 19:36:42 +0000 (+0200) Subject: Better behavior with failure X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=7ac93837eec53c30594aef0480458e0caf8f1d5c;p=pciids.git Better behavior with failure The database is rolled back, so it should contain no locks (the transaction has ended). --- diff --git a/PciIds/Html/Handler.pm b/PciIds/Html/Handler.pm index 24f33cf..da7c10f 100644 --- a/PciIds/Html/Handler.pm +++ b/PciIds/Html/Handler.pm @@ -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; }