Index: trunk/pstamp/scripts/detectability_respond.pl
===================================================================
--- trunk/pstamp/scripts/detectability_respond.pl	(revision 27642)
+++ trunk/pstamp/scripts/detectability_respond.pl	(revision 27643)
@@ -81,5 +81,5 @@
     run(command => $dqr_command, verbose => $verbose);
 unless ($success) {
-    warn("Unable to perform $dqr_command error code: $error_code");
+    my_die("Unable to perform $dqr_command error code: $error_code",-1,-1,-1,-1,-1,-1);
 }
 my %query = ();
@@ -125,4 +125,9 @@
 					$query{CONTENT}{RA1_DEG}[$i],$query{CONTENT}{DEC1_DEG}[$i],
 					$query{CONTENT}{ROWNUM}[$i],$verbose);
+    unless (%$image_set_tmp) {
+	my_die("No images were returned.",$query{HEADER}{QUERY_ID}[0],$query{HEADER}{FPA_ID}[0],
+	       $query{HEADER}{MJD_OBS}[0],$query{HEADER}{FILTER}[0],$query{HEADER}{OBSCODE}[0],
+	       $query{HEADER}{STAGE}[0]);
+    }
     print "=== $image_set_tmp->{IMAGE}\n    $image_set_tmp->{PSF}\n    $image_set_tmp->{MASK}\n    $image_set_tmp->{WEIGHT}\n    $image_set_tmp->{SKY_COORDINATES}\n    $image_set_tmp->{ROWNUM}\n";
     # This appends, assuming that if we get an image, we also get the identical psf/mask/weight/etc.
@@ -154,5 +159,8 @@
 	run(command => $command, verbose => $verbose);
     unless ($success) {
-	warn("Unable to perform $command error code: $error_code");
+	my_die("Unable to perform $command. Error_code: $error_code",
+	       $query{HEADER}{QUERY_ID}[0],$query{HEADER}{FPA_ID}[0],
+	       $query{HEADER}{MJD_OBS}[0],$query{HEADER}{FILTER}[0],$query{HEADER}{OBSCODE}[0],
+	       $query{HEADER}{STAGE}[0],$error_code);
     }
     my @response = split /\n/, (join "", @$stdout_buf);
@@ -177,5 +185,8 @@
 	run(command => $psphot_cmd, verbose => $verbose);
     unless ($success) {
-	warn ("Unable to perform $psphot_cmd error code: $error_code");
+	my_die("Unable to perform $psphot_cmd. Error_code: $error_code",
+	       $query{HEADER}{QUERY_ID}[0],$query{HEADER}{FPA_ID}[0],
+	       $query{HEADER}{MJD_OBS}[0],$query{HEADER}{FILTER}[0],$query{HEADER}{OBSCODE}[0],
+	       $query{HEADER}{STAGE}[0],$error_code);
     }
 }
@@ -253,5 +264,6 @@
 		# Diffs match if either exposure name is defined and matches the FPA_ID
 		unless ((defined(${ $j }{exp_name_1}) && (${ $j }{exp_name_1} eq $FPA_ID))||
-			(defined(${ $j }{exp_name_2}) && (${ $j }{exp_name_2} eq $FPA_ID))) {
+			(defined(${ $j }{exp_name_2}) && (${ $j }{exp_name_2} eq $FPA_ID))||
+			(${ $j }{exp_id_1} eq $FPA_ID)||(${ $j }{exp_id_2} eq $FPA_ID)) {
 		    next;
 		}
@@ -268,12 +280,12 @@
 		# For all the other stages (warp and chip are the ones I've tested), we can simply 
 		# directly match the exposure name to the FPA_ID
-		if (${ $j }{exp_name} ne $FPA_ID) {
+		unless ((${ $j }{exp_name} eq $FPA_ID)||(${ $j }{exp_id} eq $FPA_ID)) {
 		    next;
 		}
 	    }
 	    # Debug prints of all the components of this image
-#  	    foreach my $k (keys %{ $j }) {
-# 		print "$i $j $k ${ $j }{$k}\n";
-# 	    }
+  	    foreach my $k (keys %{ $j }) {
+ 		print "$i $j $k ${ $j }{$k}\n";
+ 	    }
 	    
 	    # This image matches, so we want to save the information into our output structure
@@ -499,2 +511,20 @@
     }
 }
+
+sub my_die {
+    my $message = shift;
+    my $QUERY_ID = shift;
+    my $FPA_ID = shift;
+    my $MJD_OBS = shift;
+    my $FILTER = shift;
+    my $OBSCODE = shift;
+    my $STAGE = shift;
+
+    my $exit_code = shift;      # Exit code to add
+
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
+    carp("$message : $QUERY_ID $FPA_ID $MJD_OBS $FILTER $OBSCODE $STAGE");
+    exit($exit_code);
+
+}
