Changeset 492


Ignore:
Timestamp:
Apr 27, 2010, 8:50:55 AM (10 years ago)
Author:
lucas
Message:

couch-dump and couch-load: use STDERR or die for errors (closes #13)

Location:
couchdb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • couchdb/couch-dump

    r474 r492  
    5858my $dbinfo = $db->db_info();
    5959if (defined $dbinfo->{error} and $dbinfo->{error} eq 'not_found') {
    60   print "Database $db_name does not seem to exist, aborting!\n";
    61   exit 1;
     60  die "Database $db_name does not seem to exist, aborting!\n";
    6261}
    6362
     
    6665# ensure we're safe by forcing an empty directory
    6766if (-d $output_dir) {
    68   print "Please remove or rename the destination directory $output_dir before running $0.\n";
    69   exit 1;
     67  die "Please remove or rename the destination directory $output_dir before running $0.\n";
    7068}
    7169
  • couchdb/couch-load

    r474 r492  
    6363# ensure we're reading something that looks like a dump
    6464if (not -d $source_dir) {
    65   print "The directory $source_dir must exist.\n";
    66   exit 1;
     65  die "The directory $source_dir must exist.\n";
    6766}
    6867
     
    7170my @docs = glob "doc_*";
    7271if (scalar @docs == 0) {
    73   print "The directory $source_dir does not seem to contain any documents, aborting!\n";
    74   exit 1;
     72  die "The directory $source_dir does not seem to contain any documents, aborting!\n";
    7573}
    7674
     
    107105 
    108106  $result = $db->create_named_doc($content, '_design/' . $id);
    109   print "\nError creating design document $id: " . $rs->errstr,"\n" if $rs->err;
     107  # print error but don't quit
     108  print STDERR "\nError creating design document '$id': " . $rs->errstr,"\n" if $rs->err;
    110109}
    111110
     
    117116 
    118117  $result = $db->create_named_doc($content, $id);
    119   print "\nError creating document $id: " . $rs->errstr,"\n" if $rs->err;
     118  # print error but don't quit
     119  print STDERR "\nError creating document $id: " . $rs->errstr,"\n" if $rs->err;
    120120
    121121  # handle attachments
     
    138138      # couch responds with "201 - Created" if everything went well
    139139      if (not $client->responseCode() eq '201') {
    140         print "Got unexpected response from CouchDB:\n";
    141         print $client->responseCode(),"\n";
    142         print $client->responseContent(),"\n";
     140        print STDERR "Got unexpected response from CouchDB:\n";
     141        print STDERR $client->responseCode(),"\n";
     142        print STDERR $client->responseContent(),"\n";
    143143      }
    144144    }
Note: See TracChangeset for help on using the changeset viewer.