IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11728


Ignore:
Timestamp:
Feb 8, 2007, 5:55:22 PM (19 years ago)
Author:
Paul Price
Message:

Removing croak in favour of carp followed by exit, using an appropriate exit code.

Location:
trunk/PS-IPP-Config/lib/PS/IPP
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/PS-IPP-Config/lib/PS/IPP/Config.pm

    r11647 r11728  
    11# Copyright (c) 2006  Paul Price, Joshua Hoblitt
    22#
    3 # $Id: Config.pm,v 1.28 2007-02-03 07:55:38 jhoblitt Exp $
     3# $Id: Config.pm,v 1.29 2007-02-09 03:55:22 price Exp $
    44
    55package PS::IPP::Config;
     
    1010our $VERSION = '1.00';
    1111
    12 use Carp qw( carp croak );
     12use Carp qw( carp );
    1313use File::Spec;
    1414use PS::IPP::Metadata::Config 0.07;
     
    5757    my $name;                   # Name of ipprc file
    5858    GetOptions( 'site=s' => \$name );
    59     $name = $ENV{PS_SITE} if not defined $name;
    60     $name = $ENV{HOME} . '/.ipprc' if not defined $name;
    61 
    62     open my $file, $name or croak "Unable to open ipprc file $name: $!";
     59    $name = $ENV{PS_SITE} unless defined $name;
     60    $name = $ENV{HOME} . '/.ipprc' unless defined $name;
     61
     62    open my $file, $name;
     63    unless ($file) {
     64        carp "Unable to open ipprc file $name: $!";
     65        exit($PS_EXIT_CONFIG_ERROR);
     66    }
    6367    my @contents = <$file>;     # Contents of the ipprc file
    6468    close $file;
     
    6771
    6872    my $path = _interpolate_env(_mdLookupStr($mdc, 'PATH')); # The path
    69     croak "PATH is not set in $name\n" unless defined $path;
     73    unless (defined $path) {
     74        carp "PATH is not set in $name\n";
     75        exit($PS_EXIT_CONFIG_ERROR);
     76    }
    7077
    7178    # Interpolate environment variables in the work directory
     
    96103    my $camera_list = _mdLookupMD($self->{_ipprc}, 'CAMERAS'); # List of cameras
    97104    my $filename = _mdLookupStr($camera_list, $name); # Filename of camera configuration
    98     croak "Unable to find configuration file for camera $name\n"
    99         if not defined $filename;
     105    unless (defined $filename) {
     106        carp "Unable to find configuration file for camera $name\n";
     107        exit($PS_EXIT_CONFIG_ERROR);
     108    }
    100109
    101110    my @path = split /:/, $self->{path}; # List of paths to try
     
    119128            $tries ++;
    120129            if ($tries > 4) {
    121                 croak "Unable to find camera configuration file $filename\n" if not $found;
     130                unless ($found) {
     131                    carp "Unable to find camera configuration file $filename\n";
     132                    exit($PS_EXIT_CONFIG_ERROR);
     133                }
    122134            }
    123135            ## try again after a moment?
     
    128140
    129141    # Read the file
    130     open my $file, $realfile or croak "Unable to open camera configuration file $realfile: $!";
     142    open my $file, $realfile;
     143    unless ($file) {
     144        carp "Unable to open camera configuration file $realfile: $!";
     145        exit($PS_EXIT_CONFIG_ERROR);
     146    }
    131147    my @contents = <$file>;
    132148    close $file;
     
    151167    my $path_list = _mdLookupMD($self->{_ipprc}, 'DATAPATH'); # List of paths
    152168    my $pathname = _mdLookupStr($path_list, $name); # Path of interest
    153     croak "Unable to find camera configuration file $pathname\n" if not defined $pathname;
     169    unless (defined $pathname) {
     170        carp "Unable to find camera configuration file $pathname\n" ;
     171        exit($PS_EXIT_CONFIG_ERROR);
     172    }
    154173
    155174    return $pathname;
     
    274293  TYPES: foreach my $item (@$rejection) {
    275294      if (lc($item->{name}) eq $type) {
    276           croak "$name within REJECTION is not of type METADATA" unless $item->{class} eq "metadata";
     295          unless ($item->{class} eq "metadata") {
     296              carp "$name within REJECTION is not of type METADATA";
     297              exit($PS_EXIT_PROG_ERROR);
     298          }
    277299          my $limits = $item->{value}; # List of rejection limits
    278300
  • trunk/PS-IPP-Config/lib/PS/IPP/Metadata/Stats.pm

    r9522 r11728  
    11# Copyright (c) 2006  Paul Price, Joshua Hoblitt
    22#
    3 # $Id: Stats.pm,v 1.12 2006-10-12 23:42:56 price Exp $
     3# $Id: Stats.pm,v 1.13 2007-02-09 03:55:22 price Exp $
    44
    55package PS::IPP::Metadata::Stats;
     
    1010our $VERSION = '0.02';
    1111
    12 use Carp qw( carp croak );
     12use Carp qw( carp );
    1313use Statistics::Descriptive;
     14
     15use PS::IPP::Config qw(
     16    $PS_EXIT_SUCCESS
     17    $PS_EXIT_UNKNOWN_ERROR
     18    $PS_EXIT_SYS_ERROR
     19    $PS_EXIT_CONFIG_ERROR
     20    $PS_EXIT_PROG_ERROR
     21    $PS_EXIT_DATA_ERROR
     22    $PS_EXIT_TIMEOUT_ERROR
     23    );
    1424
    1525use base qw( Class::Accessor::Fast );
     
    233243    }
    234244
    235     croak "Unrecognised type (", $type, ") for value of ", $name, "\n";
     245    carp "Unrecognised type (", $type, ") for value of ", $name, "\n";
     246    exit($PS_EXIT_PROG_ERROR);
    236247    return;
    237248}
Note: See TracChangeset for help on using the changeset viewer.