static const char* version_id =
  "$Id: action_evaluation.cc,v 1.3 1999/08/13 17:46:04 v2kea318 Exp $";

// $Log: action_evaluation.cc,v $
// Revision 1.3  1999/08/13  17:46:04  v2kea318
// Rewrote the << operator for the action_failed exception to exploit the
// fact that the failure codes are of the form 0xF?.
//
// Revision 1.2  1999/05/07  15:44:42  v2kea318
// Added the << operator for the action_failed exception.
//
// Revision 1.1  1999/05/05  15:06:10  v2kea318
// Initial revision
//
//***************************************************************************

#include "action_evaluation.h"

//***************************************************************************

void eval_response(const Socket& s)
{
  msg_action_code resp;
  read(s, resp);
  if (resp != success) throw action_failed(resp);
}

//***************************************************************************

ostream& operator << (ostream& os, const action_failed& af)
{
  msg_action_code fcode = af.failure_code();
  os << af.what() << " with code " << (int) fcode << " which indicates ";
  fcode &= 0x0F;  // get the lower nibble of the code.
  const char* emsgs[] = {
      "",
      "unregistered user id",
      "action code not recognized",
      "insufficient data transferred",
      "an error occured in data transfer"
  };
  os << ((fcode == 0x0F) ? "general failure" : emsgs[fcode]);
  return os;
}
