Index: /trunk/pstamp/scripts/pstamp_finish.pl
===================================================================
--- /trunk/pstamp/scripts/pstamp_finish.pl	(revision 28228)
+++ /trunk/pstamp/scripts/pstamp_finish.pl	(revision 28229)
@@ -76,5 +76,5 @@
 if ($product eq "NULL") {
     # nothing more to do
-    stop_request_and_exit($req_id, $PS_EXIT_PROG_ERROR);
+    my_die("product is NULL!", $req_id, $PS_EXIT_PROG_ERROR);
 }
 
@@ -92,19 +92,14 @@
 
         if (!mkdir $outdir) {
-            print STDERR "cannot create output directory $outdir";
-            stop_request_and_exit($req_id, $PS_EXIT_UNKNOWN_ERROR);
+            my_die("cannot create output directory $outdir",$req_id, $PS_EXIT_UNKNOWN_ERROR);
         }
 
 
     } elsif (! -d $outdir ) {
-        # XXX TODO: fault the request so we pstamp_finish doesn't keep trying to process the
-        # request
-        print STDERR "output directory $outdir exists but is not a directory";
-        stop_request_and_exit($req_id, $PS_EXIT_UNKNOWN_ERROR);
+        my_die("output directory $outdir exists but is not a directory", $req_id, $PS_EXIT_UNKNOWN_ERROR);
     }
 
     if (! -e $req_file ) {
-        print STDERR "request file $req_file is missing\n";
-        stop_request_and_exit($req_id, $PS_EXIT_CONFIG_ERROR);
+        my_die("request file $req_file is missing", $req_id, $PS_EXIT_CONFIG_ERROR);
     }
 
@@ -115,6 +110,5 @@
         # Since a request got queued, the request file must have been readable at some
         # point 
-        print STDERR "failed to read request_file $req_file" ;
-        stop_request_and_exit($req_id, $PS_EXIT_CONFIG_ERROR);
+        my_die("failed to read request file $req_file", $req_id, $PS_EXIT_CONFIG_ERROR);
     }
 
@@ -151,15 +145,7 @@
         my $output = join "", @$stdout_buf;
         if (!$output) {
-            if ($verbose) {
-                print STDERR "Request $req_id produced no jobs.\n"
-            }
             # This should not happen. A fake job should have been entered
-            stop_request_and_exit($req_id, $PS_EXIT_PROG_ERROR);
+            my_die("Request $req_id produced no jobs", $req_id, $PS_EXIT_PROG_ERROR);
         } else {
-if (0) {
-            my $metadata = $mdcParser->parse($output) or die("Unable to parse metdata config doc");
-
-            my $jobs = parse_md_list($metadata);
-}
             my $jobs = parse_md_fast($mdcParser, $output);
 
@@ -181,5 +167,5 @@
             # this request had a duplicate request name yet the parser didn't give
             # it an "ERROR style name.
-            stop_request_and_exit($req_id, $PS_EXIT_PROG_ERROR);
+            my_die("duplicate request not given a request name", $req_id, $PS_EXIT_PROG_ERROR);
         }
         my ($row, $req_info, $project) = get_request_info($rows, $rownum);
@@ -187,9 +173,7 @@
         my $proj_hash = resolve_project($ipprc, $project, $dbname, $dbserver);
         my $image_db = $proj_hash->{dbname};
-        if (!$image_db) {
-            carp("failed to find imagedb for project: $project");
-            if (!$fault) {
-                stop_request_and_exit($req_id, $PS_EXIT_CONFIG_ERROR);
-            }
+        if (!$image_db and !$fault) {
+            # if project isn't resolvable, the paser should have faulted this job
+            my_die("failed to find imagedb for project $project", $req_id, $PS_EXIT_CONFIG_ERROR);
         }
 
@@ -273,7 +257,6 @@
                 run(command => $command, verbose => $verbose);
             unless ($success) {
-                print STDERR "Unable to perform $command error code: $error_code\n";
                 $request_fault = $error_code >> 8;
-                stop_request_and_exit($req_id, $request_fault);
+                my_die("Unable to perform $command error code: $error_code", $req_id, $request_fault);
             }
         }
@@ -283,14 +266,10 @@
         my $command = "$dsreg --list $reglist_name --add $fileset --product $product --type PSRESULTS";
         $command .= " --link --datapath $outdir --ps0 $req_id";
-# XXX: let dsreg and config handle resolving dbname and dbserver
-#        $command .= " --dbname $dbname" if $dbname;
 
         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
             run(command => $command, verbose => $verbose);
         unless ($success) {
-            #die("Unable to perform $command error code: $error_code");
-            print STDERR "Unable to perform $command error code: $error_code\n";
             $request_fault = $error_code >> 8;
-            stop_request_and_exit($req_id, $request_fault);
+            my_die("Unable to perform $command error code: $error_code\n", $req_id, $request_fault);
         }
     }
@@ -309,8 +288,10 @@
 }
 
-sub stop_request_and_exit {
-    # this no longer stops the request. Arguably this should be an old fashioned mydie
+sub my_die {
+    my $msg = shift;
     my $req_id = shift;
     my $fault  = shift;
+
+    carp($msg);
 
     my $command = "$pstamptool -updatereq -req_id $req_id -set_fault $fault";
@@ -447,9 +428,4 @@
                 return undef;
             }
-if (0) {
-            my $metadata = $mdcParser->parse($output) or die("Unable to parse metdata config doc");
-
-            my $exposures = parse_md_list($metadata);
-}
             my $exposures = parse_md_fast($mdcParser, $output);
             my $numExp = @$exposures;
