From 7ac93837eec53c30594aef0480458e0caf8f1d5c Mon Sep 17 00:00:00 2001 From: Michal Vaner Date: Mon, 25 Aug 2008 21:36:42 +0200 Subject: [PATCH] Better behavior with failure The database is rolled back, so it should contain no locks (the transaction has ended). --- PciIds/Html/Handler.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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; } -- 2.39.2