[libmagpie-perl] 03/09: Protect the individual setter calls in a PUT update with a try/catch block.

Jonas Smedegaard js at moszumanska.debian.org
Mon Jan 27 19:30:33 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository libmagpie-perl.

commit b9e89b310debc768b6c3446e4c5287e4047bc7af
Author: Kip Hampton <khampton at totalcinema.com>
Date:   Sun Jan 26 09:47:14 2014 -0800

    Protect the individual setter calls in a PUT update with a try/catch block.
---
 lib/Magpie/Resource/Kioku.pm | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/Magpie/Resource/Kioku.pm b/lib/Magpie/Resource/Kioku.pm
index 2e876aa..a63b405 100644
--- a/lib/Magpie/Resource/Kioku.pm
+++ b/lib/Magpie/Resource/Kioku.pm
@@ -328,10 +328,19 @@ sub PUT {
     }
 
     foreach my $key (keys(%args)) {
-        $existing->$key( $args{$key} );
+        try {
+            $existing->$key( $args{$key} );
+        }
+        catch {
+            my $error = "Error updating property '$key' of Resource ID $existing_id: $_\n";
+            $self->set_error( { status_code => 500, reason => $error } );
+            last;
+        };
     }
 
 
+    return OK if $self->has_error;
+
     try {
         $self->data_source->txn_do(sub {
             my $scope = $self->data_source->new_scope;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmagpie-perl.git



More information about the Pkg-perl-cvs-commits mailing list