コード例 #1
0
///////////////////////////////////////////////////////////////////////////////
/// @fn void error_logger( const Exception& e )
/// @brief Writes e to a file and also to the screen.
/// @pre e exists.
/// @param const Exception& e - The Exception to write to file and screen.
/// @post Writes e to a file and also to the screen.
/// @return None.
///////////////////////////////////////////////////////////////////////////////
void error_logger( const Exception& e )
{
    // Store the error message for output to file and screen.
    string msg = "Exception: " + e.get_errorMsg();

    // Show the message to the screen.
    cout << msg << endl;

    return;
}
コード例 #2
0
///////////////////////////////////////////////////////////////////////////////
/// @fn void error_logger( const Exception& e )
/// @brief Writes e to a file and also to the screen.
/// @pre e exists.
/// @param const Exception& e - The Exception to write to file and screen.
/// @post Writes e to a file and also to the screen.
/// @return None.
///////////////////////////////////////////////////////////////////////////////
void error_logger( const Exception& e ) 
{
  //Create/open the log file.
  File elog( "errorlog.txt" );
  
  //Store the error message for output to file and screen.
  string msg = "Exception " + int_to_str( e.get_errorCode() ) + ": " + e.get_errorMsg();
  
  //Insert the error at the end of the file.
  elog.insert_line( elog.get_num_lines(), msg );
  
  //Save the file, then close it.
  elog.close(true);
  
  //Show the message to the screen.
  cout << msg << endl;

  return;
}