Index: trunk/ippScripts/scripts/lossy_compress_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/lossy_compress_imfile.pl	(revision 28137)
+++ trunk/ippScripts/scripts/lossy_compress_imfile.pl	(revision 28141)
@@ -61,7 +61,7 @@
     defined $state;
 
-my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $exp_id, $exp_name, $class_id, $uri, $PS_EXIT_CONFIG_ERROR );
+my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $exp_id, $exp_name, $class_id, $uri, $state, $PS_EXIT_CONFIG_ERROR );
 if (defined($logfile)) {
-    $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $exp_id, $exp_name, $class_id, $uri, $PS_EXIT_SYS_ERROR );
+    $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $exp_id, $exp_name, $class_id, $uri, $state, $PS_EXIT_SYS_ERROR );
 }
 
@@ -87,5 +87,5 @@
 if ($state eq 'goto_compressed') {
     # Find the actual filename for this run:
-    &my_die("Couldn't find input file: $uri\n", $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR)
+    &my_die("Couldn't find input file: $uri\n", $exp_id,$exp_name,$class_id,$uri,$state,$PS_EXIT_SYS_ERROR)
         unless ($ipprc->file_exists($uri));
     my $uriReal = $ipprc->file_resolve( $uri );
@@ -93,5 +93,5 @@
     # Create a compressed version:
     my $compUri = $uri . ".fz";
-    &my_die("Output compressed file already exists: $compUri\n", $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR)
+    &my_die("Output compressed file already exists: $compUri\n", $exp_id,$exp_name,$class_id,$uri,$state,$PS_EXIT_SYS_ERROR)
         if ($ipprc->file_exists($compUri));
     my $compReal= $ipprc->file_resolve( $compUri, 'create');
@@ -109,5 +109,5 @@
         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
         &my_die("Unable to uncompress file: $uri -> $compUri: $error_code",
-                $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);
+                $exp_id,$exp_name,$class_id,$uri, $state, $PS_EXIT_SYS_ERROR);
     }
     my $compress_command = "$fpack -h -s 8 -S $tempReal >  $compReal";
@@ -118,10 +118,10 @@
         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
         &my_die("Unable to compress file: $uri -> $compUri: $error_code",
-                $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);
+                $exp_id,$exp_name,$class_id,$uri, $state, $PS_EXIT_SYS_ERROR);
     }
     my $database_command = "$regtool -updateprocessedimfile -exp_id $exp_id -class_id $class_id -set_state compressed";
     $database_command .= " -dbname $dbname" if defined $dbname;
 
-    &my_die("Expected output compressed file not found: $compUri\n", $exp_id,$exp_name,$class_id, $uri,$PS_EXIT_SYS_ERROR)
+    &my_die("Expected output compressed file not found: $compUri\n", $exp_id,$exp_name,$class_id, $uri,$state, $PS_EXIT_SYS_ERROR)
         unless ($ipprc->file_exists($compUri));
 
@@ -135,5 +135,5 @@
             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
             &my_die("Unable to update database file: $uri -> $compUri: $error_code",
-                    $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);
+                    $exp_id,$exp_name,$class_id,$uri, $state, $PS_EXIT_SYS_ERROR);
         }
     }
@@ -149,5 +149,5 @@
 if ($state eq 'goto_lossy') {
     # Confirm we have both files
-    &my_die("Couldn't find original file: $uri\n", $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR)
+    &my_die("Couldn't find original file: $uri\n", $exp_id,$exp_name,$class_id,$uri,$state,$PS_EXIT_SYS_ERROR)
         unless($ipprc->file_exists($uri));
     my $uriReal = $ipprc->file_resolve( $uri );
@@ -156,5 +156,5 @@
     unless($ipprc->file_exists($compUri)) {
         &my_die("Couldn't find compressed version of the file: $compUri\n",
-                $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR);
+                $exp_id,$exp_name,$class_id,$uri,$state,$PS_EXIT_SYS_ERROR);
 
         # If that die is removed, this will compress things as well.
@@ -185,5 +185,5 @@
         $neb->swap($uri,$compUri) or
             &my_die("Nebulous swap failed between $uri and $compUri",
-                    $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR);
+                    $exp_id,$exp_name,$class_id,$uri,$state,$PS_EXIT_SYS_ERROR);
     }
     # Update database
@@ -204,7 +204,7 @@
             $neb->swap($uri,$compUri) or
                 &my_die("DB update failed and Nebulous swap-back failed between $uri and $compUri",
-                        $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR);
+                        $exp_id,$exp_name,$class_id,$uri,$state,$PS_EXIT_SYS_ERROR);
             &my_die("Unable to update database file: $uri -> $compUri: $error_code",
-                    $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);
+                    $exp_id,$exp_name,$class_id,$uri, $state,$PS_EXIT_SYS_ERROR);
         }
         # remove original version
@@ -224,6 +224,16 @@
     my $class_id = shift; # Class identifier
     my $uri = shift; # uri for the file
+    my $state = shift;
     my $exit_code = shift; # Exit code
     # outputImage and path_base are globals
+    my $fail_state = $state;
+    $fail_state =~ s/goto_/error_/;
+    my $error_command = "$regtool -updateprocessedimfile -exp_id $exp_id -class_id $class_id -set_state $fail_state ";
+    $error_command .= " -dbname $dbname" if defined $dbname;
+    my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =
+	run(command => $error_command, verbose => $verbose);
+    unless($success) {
+	warn("Failed at setting the error state too.");
+    }
 
     $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
