Changeset 22852


Ignore:
Timestamp:
09/06/10 11:47:57 (11 years ago)
Author:
kjdon
Message:

now prints errors to outhandle, failhandle and gli xml instead of just to STDERR

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/MetadataCSVPlugin.pm

    r20804 r22852  
    3030use BasePlugin;
    3131use strict;
    32 
     32no strict 'refs';
    3333use multiread;
    3434
     
    108108    print STDERR "\n<Processing n='$file' p='MetadataCSVPlugin'>\n" if ($gli);
    109109    print STDERR "MetadataCSVPlugin: processing $file\n" if ($self->{'verbosity'}) > 1;
     110
     111    my $outhandle = $self->{'outhandle'};
     112    my $failhandle = $self->{'failhandle'};
    110113
    111114    # add the file to the block list so that it won't be processed in read, as we will do all we can with it here
     
    136139
    137140    if (!$found_filename_field) {
    138     print STDERR "MetadataCSVPlugin Error: No Filename field in CSV file: $filename\n";
     141    $self->print_error($outhandle, $failhandle, $gli, $filename, "No Filename field in CSV file");
    139142    return -1; # error
    140143    }
     
    171174        # The line must be formatted incorrectly
    172175        else {
    173         print STDERR "MetadataCSVPlugin Error: Badly formatted CSV line: $csv_line.\n";
     176        $self->print_error($outhandle, $failhandle, $gli, $filename, "Badly formatted CSV line: $csv_line");
    174177        last;
    175178        }
     
    181184    my $csv_line_filename_array = $csv_line_metadata{"Filename"};
    182185    if (!defined $csv_line_filename_array) {
    183         print STDERR "MetadataCSVPlugin Error: No Filename metadata in CSV line: $orig_csv_line\n";
     186        $self->print_error($outhandle, $failhandle, $gli, $filename, "No Filename metadata in CSV line: $orig_csv_line");
    184187        next;
    185188    }
     
    202205}
    203206
    204 
     207sub print_error
     208{
     209
     210    my $self = shift(@_);
     211    my ($outhandle, $failhandle, $gli, $file, $error) = @_;
     212
     213    print $outhandle "MetadataCSVPlugin Error: $file: $error\n";
     214    print $failhandle "MetadataCSVPlugin Error: $file: $error\n";
     215    print STDERR "<ProcessingError n='$file' r='$error'/>\n" if ($gli);
     216}
    2052171;
Note: See TracChangeset for help on using the changeset viewer.