[Bps-public-commit] r16609 - sd/trunk/lib/App/SD/Replica/hm

ruz at bestpractical.com ruz at bestpractical.com
Wed Oct 29 18:03:00 EDT 2008


Author: ruz
Date: Wed Oct 29 18:02:55 2008
New Revision: 16609

Modified:
   sd/trunk/lib/App/SD/Replica/hm/PushEncoder.pm

Log:
* add decode_error method in hm's pusher

Modified: sd/trunk/lib/App/SD/Replica/hm/PushEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/hm/PushEncoder.pm	(original)
+++ sd/trunk/lib/App/SD/Replica/hm/PushEncoder.pm	Wed Oct 29 18:02:55 2008
@@ -68,6 +68,9 @@
         repeat_stacking => 0,
         %{ $self->_recode_props_for_create($change) }
     );
+    unless ( $task->{'success'} ) {
+        die "Couldn't create a task: ". $self->decode_error( $task );
+    }
 
     my $txns = $self->sync_source->hm->search( 'TaskTransaction', task_id => $task->{content}->{id} );
 
@@ -76,6 +79,19 @@
     return $task->{content}->{id};
 }
 
+sub decode_error {
+    my $self = shift;
+    my $status = shift;
+    my $msg = '';
+    $msg .= $status->{'error'} if defined $status->{'error'};
+    if ( $status->{'field_errors'} ) {
+        while ( my ($k, $v) = each %{ $status->{'field_errors'} } ) {
+            $msg .= "field '$k' - '$v'\n";
+        }
+    }
+    return $msg;
+}
+
 sub integrate_comment {
     my $self = shift;
     my ($change, $changeset) = validate_pos( @_, { isa => 'Prophet::Change' }, {isa => 'Prophet::ChangeSet'} );
@@ -93,7 +109,7 @@
     );
     return $status->{'content'}{'id'} if $status->{'success'};
 
-    die "Couldn't integrate comment: ". $status->{'error'};
+    die "Couldn't integrate comment: ". $self->decode_error( $status );
 }
 
 sub integrate_ticket_update {
@@ -113,7 +129,7 @@
     );
     return $status->{'content'}{'id'} if $status->{'success'};
 
-    die "Couldn't integrate comment: ". $status->{'error'};
+    die "Couldn't integrate comment: ". $self->decode_error( $status );
 }
 
 sub _recode_props_for_create {



More information about the Bps-public-commit mailing list