Index: /trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm
===================================================================
--- /trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm	(revision 27993)
+++ /trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm	(revision 27994)
@@ -170,8 +170,7 @@
 
 # The subroutine lookup handles byexp, byid, and byskycell lookups including lookups that are
-# triggered by a bydiff request
-
-sub lookup
-{
+# triggered by a bydiff or bycoord request
+
+sub lookup {
     my $ipprc    = shift;
     my $rowList    = shift;
@@ -207,4 +206,5 @@
     my $class_id;
     my $skycell_id;
+    my $default_error = $PSTAMP_NO_IMAGE_MATCH;
 
     # note $magic_arg may be cleared below depending on $req_type
@@ -533,5 +533,7 @@
             if (($img_type ne "diff") and ($img_type ne "stack")) {
                 print STDERR "lookup_diff: cannot lookup IMG_TYPE $img_type bydiff from a stack stack diff run\n";
-                next;
+                setErrorCodes($rowList, $PSTAMP_INVALID_REQUEST);
+                # all images will be the same so we can stop
+                last;
             }
             # stack-stack diff
@@ -601,5 +603,5 @@
             } else {
                 # XXX this will only happen if the minuend is not a warp. See hack above
-                print STDERR "WARNING: cannot resolve camera so cannot get resolve file rules\n";
+                print STDERR "WARNING: cannot resolve camera so cannot find file rules\n";
                 next;
             }
@@ -1085,4 +1087,6 @@
         print $pointsList "$npoints $row->{CENTER_X} $row->{CENTER_Y}\n";
         $npoints++;
+        # this gets overwitten if an overlapping image is found
+        $row->{error_code} = $PSTAMP_NO_OVERLAP;
     }
     close $pointsList;
@@ -1129,4 +1133,7 @@
                 }
                 push @$ref, $ptnum;
+                my $row = $rowList->[$ptnum];
+                # this row found a match
+                $row->{error_code} = 0;
             }
             if ($verbose) {
@@ -1160,7 +1167,7 @@
                 my $images = runToolAndParse($command, $verbose);
                 if (!defined $images) {
-                    # XXX: need to get the set error_code to $PSTAMP_NO_OVERLAP
                     print "No components containing coordinates found for ${stage}_id $stage_id\n";
                     foreach my $row (@$rowList) {
+                        # XXX: This doesn't seem like the correct error code?
                         $row->{error_code} = $PSTAMP_NO_OVERLAP;
                     }
@@ -1323,4 +1330,12 @@
     }
 }
+# set error_code for an array of rows to a given value
+sub setErrorCodes {
+    my $rowList = shift;
+    my $code = shift;
+    foreach my $row (@$rowList) {
+        $row->{error_code} = $code;
+    }
+}
 
 sub my_die
