IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26215 for trunk/pstamp/scripts


Ignore:
Timestamp:
Nov 20, 2009, 12:18:48 PM (17 years ago)
Author:
bills
Message:

add my_die function to insure that the intended fault code gets returned to the caller

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/scripts/pstamp_get_image_job.pl

    r26214 r26215  
    5151$err .= "--output_base is required to specify the output fileset\n" if (!$output_base);
    5252
    53 die $err if $err;
     53my_die( $err, $PS_EXIT_PROG_ERROR) if $err;
    5454
    5555my $params_file = $output_base . ".mdc";
    5656if (! open(INPUT, "<$params_file") ) {
    57     die("failed to open params file: $params_file");
     57    my_die("failed to open params file: $params_file", $PS_EXIT_UNKNOWN_ERROR);
    5858}
    5959
    6060my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    6161
    62 my $data = $mdcParser->parse(join "", (<INPUT>)) or die("failed to parse metadata config doc");
     62my $data = $mdcParser->parse(join "", (<INPUT>)) or my_die("failed to parse metadata config doc", $PS_EXIT_UNKNOWN_ERROR);
    6363my $components = parse_md_list($data);
    6464my $n = scalar @$components;
    6565if ($n != 1) {
    66     die("params file $params_file contains unexpected number of components: $n");
     66    my_die("params file $params_file contains unexpected number of components: $n", $PS_EXIT_PROG_ERROR);
    6767}
    6868my $comp = $components->[0];
     
    8484
    8585if (!$camera or !$path_base or !$component or !$stage_id or !$stage) {
    86        die "failed to parse params from: $params_file";
     86       my_die("failed to parse params from: $params_file", $PS_EXIT_UNKNOWN_ERROR);
    8787}
    8888
     
    110110        run(command => $command, verbose => $verbose);
    111111    unless ($success) {
    112         die("Unable to perform $command: $error_code");
     112        my_die("Unable to perform $command: $error_code", $error_code >> 8);
    113113    }
    114114}
    115115
    116116if (! open(RESULTS, "<$results_file")) {
    117     die("failed to open bundle results file: $results_file");
     117    my_die("failed to open bundle results file: $results_file", $PS_EXIT_UNKNOWN_ERROR);
    118118}
    119119
     
    135135        $md5sum = $val;
    136136    } else {
    137         die("unexpected tag: $tag  found in results file: $results_file");
     137        my_die("unexpected tag: $tag  found in results file: $results_file", $PS_EXIT_PROG_ERROR);
    138138    }
    139139}
     
    141141my $reglist = "$out_dir/reglist$job_id";
    142142if (! open(REGLIST, ">$reglist") ) {
    143     die("failed to open registration list: $reglist");
     143    my_die("failed to open registration list: $reglist", $PS_EXIT_UNKNOWN_ERROR);
    144144}
    145145
     
    149149
    150150exit 0;
     151
     152sub my_die {
     153    my $msg = shift;
     154    my $rc = shift;
     155
     156    print STDERR $msg;
     157    exit $rc ? $rc : $PS_EXIT_UNKNOWN_ERROR;
     158}
Note: See TracChangeset for help on using the changeset viewer.