Changeset 27112

Show
Ignore:
Timestamp:
22.03.2013 16:39:00 (7 years ago)
Author:
ak19
Message:

Adding in error processing code for when an invalid subsection is entered. Separate commit to allow easy uncommiting of the changes in this revision, so that the bugfix in the previous commit is not accidentally uncommited.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/cgiactions/metadataaction.pm

    r27111 r27112  
    793793     
    794794    if ($metamode ne "done" && $curr_secnum ne $opt_doc_secnum) { 
    795     print STDERR "@@@ $tagname Finished processing FINAL Section [$curr_secnum|$opt_doc_secnum]\n"; 
     795    print STDERR "@@@ $tagname Finished processing FINAL Section.\n"; 
    796796 
    797797    my $metaname = $parser->{'parameters'}->{'metaname'}; 
    798798    my $metavalue = $parser->{'parameters'}->{'metavalue'}; 
    799799     
    800     print STDERR "@@@ Unknown requested section number $opt_doc_secnum\n"; 
    801     print STDERR "\tas final section number in document was $curr_secnum\n"; 
    802     print STDERR "\tMetadata value '$metavalue' for meta '$metaname'\n"; 
    803     print STDERR "\tin section $opt_doc_secnum discarded.\n"; 
     800    print STDERR "@@@ Requested section number $opt_doc_secnum not found.\n"; 
     801    print STDERR "\t(last seen section number in document was $curr_secnum)\n"; 
     802    print STDERR "\tDiscarded metadata value '$metavalue' for meta '$metaname'\n"; 
     803    print STDERR "\tin section $opt_doc_secnum.\n"; 
     804    $parser->{'custom_err_msg'} = "Requested section number $opt_doc_secnum not found."; 
    804805    } 
    805806     
     
    962963    } 
    963964    } 
     965 
     966    # copy across any custom error information that was stored during parsing 
     967    $self->{'error_msg'} = $parser->{'custom_err_msg'} if(defined $parser->{'custom_err_msg'});     
    964968} 
    965969 
     
    10531057    $self->edit_doc_xml($gsdl_cgi,$doc_xml_filename, 
    10541058            $metaname,$metavalue,$metapos,$metamode,$docid_secnum,$prevmetavalue); 
    1055      
    1056     return 0; # return 0 for now to indicate no error 
     1059 
     1060    # return 0; # return 0 for now to indicate no error 
     1061    return (defined $self->{'error_msg'}) ? 1 : 0; 
    10571062} 
    10581063 
     
    11171122        my $mess .= "Failed to set archives metadata key: $docid\n"; 
    11181123        $mess .= "Exit status: $status\n"; 
    1119         $mess .= "System Error Message: $!\n"; 
     1124        if(defined $self->{'error_msg'}) { 
     1125            $mess .= "Error Message: $self->{'error_msg'}\n"; 
     1126        } else { 
     1127            $mess .= "System Error Message: $!\n"; 
     1128        } 
    11201129        $mess .= "-" x 20 . "\n"; 
    11211130