IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 43023


Ignore:
Timestamp:
May 19, 2026, 5:01:26 PM (2 months ago)
Author:
eugene
Message:

use parse_error_message to distinguish numerical error value and error message (api change for run in perl)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_finish.pl

    r42981 r43023  
    137137            $command   .= " -dbname $dbname" if $dbname;
    138138            $command   .= " -dbserver $dbserver" if $dbserver;
    139             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    140                 run(command => $command, verbose => $verbose);
     139            my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
     140            my $error_code = &parse_error_message ($success, $error_msg, $command);
    141141            unless ($success) {
    142142                die("Unable to perform $command error code: $error_code");
     
    260260        {
    261261            my $command = "$pstamp_results --input $table_def_name --output $outdir/results.fits";
    262             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    263                 run(command => $command, verbose => $verbose);
     262            my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
     263            my $error_code = &parse_error_message ($success, $error_msg, $command);
    264264            unless ($success) {
    265265                print STDERR "Unable to perform $command error code: $error_code\n";
    266                 $request_fault = $error_code >> 8;
     266                $request_fault = $error_code;
    267267            } else {
    268268                # dump a textual representation
     
    271271                    run(command => $command, verbose => $verbose);
    272272                unless ($success) {
    273                     $request_fault = $error_code >> 8;
     273                    $request_fault = $error_code;
    274274                    my_die("Unable to perform $command error code: $error_code", $req_id, $request_fault);
    275275                }
     
    288288            run(command => $command, verbose => $verbose);
    289289        unless ($success) {
    290             $request_fault = $error_code >> 8;
     290            $request_fault = $error_code;
    291291            my_die("Unable to perform $command error code: $error_code\n", $req_id, $request_fault);
    292292        }
     
    505505    return 40587.0 + ($ticks/86400.);
    506506}
     507
     508# if the program exited normally, the exit value is returned
     509# if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
     510# if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
     511sub parse_error_message {
     512    my $success = shift;
     513    my $error_msg = shift;
     514    my $command = shift;
     515
     516    if ($success) { return 0; }
     517
     518    print "raw error_msg: $error_msg\n";
     519    print "full command: $command\n";
     520
     521    if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
     522       
     523    # which of these match?
     524    my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
     525    if (defined $error_code) { return $error_code; }
     526   
     527    ($error_code) = $error_msg =~ m/died with signal (\d+)/;
     528#   if (defined $error_code) { return (128 + $error_code); }
     529    if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
     530   
     531    # probably failed to execute:
     532    return (-1*$PS_EXIT_PROG_ERROR);
     533}
Note: See TracChangeset for help on using the changeset viewer.