Changeset 2502


Ignore:
Timestamp:
2001-06-07T11:10:32+12:00 (23 years ago)
Author:
sjboddie
Message:

fixed a bug in my phindaction implementation

Location:
trunk/gsdl/src/recpt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/phindaction.cpp

    r2491 r2502  
    129129                 ostream &logout) {
    130130
    131   // must have a valid collection server
    132   recptproto *collectproto = protos->getrecptproto (args["c"], logout);
    133   if (collectproto == NULL) {
    134     logout << "phindaction::do_action called with NULL collectproto\n";
    135     textout << outconvert << disp << "_header_\n"
    136         << "Error: Attempt to get document without setting collection\n"
    137         << "_footer_\n";
    138     return true;
    139   }
    140 
    141131  unsigned long count_l, count_e, count_d;
    142132  unsigned long phrase = args["ppnum"].getulong();
     
    151141  if (args["pxml"] == "1") XMLmode = true;
    152142
     143  // must have a valid collection server
     144  recptproto *collectproto = protos->getrecptproto (args["c"], logout);
     145  if (collectproto == NULL) {
     146    output_error("phindaction: ERROR: collection not set", textout,
     147         outconvert, disp, logout, XMLmode);
     148    return true;
     149  }
    153150
    154151  // the frequency and occurances of the phrase
     
    167164   
    168165    if (word.empty()) {
    169       logout << "phindaction::do_action ERROR: No phrase number or word\n";
    170       textout << outconvert << disp << "_header_\n"
    171           << "Error: No phrase number or word."
    172           << "_footer_\n";
     166      output_error("phindaction: ERROR: no phrase number or word", textout,
     167           outconvert, disp, logout, XMLmode);
    173168      return true;
    174169    }
     
    178173   
    179174    if (result.empty()) {
    180       logout << "phindaction::do_action ERROR: The search term does not occur in the collection.";
    181       textout << outconvert << disp << "_header_\n"
    182           << "ERROR: The search term does not occur in the collection."
    183           << "_footer_\n";
     175      output_error("phindaction: The search term does not occur in the collection",
     176           textout, outconvert, disp, logout, XMLmode);
    184177      return true;
    185178    } else {
     
    937930}
    938931
     932void phindaction::output_error (const text_t &message, ostream &textout,
     933                outconvertclass &outconvert,
     934                displayclass & disp, ostream &logout,
     935                bool XMLmode) {
     936
     937  logout << outconvert << message << "\n";
     938  if (XMLmode) {
     939    textout << outconvert
     940        << "<phinddata>\n"
     941        << "<phinderror>" << message << "</phinderror>\n"
     942        << "</phinddata>\n";
     943  } else {
     944    textout << outconvert << disp
     945        << "_header_\n"
     946        << message
     947        << "_footer_\n";
     948  }
     949}
  • trunk/gsdl/src/recpt/phindaction.h

    r2491 r2502  
    9191  void toUCArray(const text_t &in, UCArray &out);
    9292
     93  void output_error (const text_t &message, ostream &textout,
     94             outconvertclass &outconvert,
     95             displayclass & disp, ostream &logout,
     96             bool XMLmode);
     97
    9398
    9499public:
Note: See TracChangeset for help on using the changeset viewer.