Commit db2c09a9 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

rest of doku for error

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 1104
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 15447435
// this is <README>
// ----------------------------------------------------------------------------
// $Id: README,v 1.6 2002-11-27 13:05:40 forbrig Exp $
// $Id: README,v 1.7 2002-11-27 13:20:03 forbrig Exp $
//
// Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
//
......@@ -18,7 +18,7 @@
\since November 2002
\date November 2002
\version V1.0
$Id: README,v 1.6 2002-11-27 13:05:40 forbrig Exp $
$Id: README,v 1.7 2002-11-27 13:20:03 forbrig Exp $
\section main_aims Aims
......@@ -57,6 +57,7 @@ $Id: README,v 1.6 2002-11-27 13:05:40 forbrig Exp $
\sa tfxx::error
\sa tfxx::error::Exception
\sa error.h
\sa \ref group_error
\section main_namespaces Namespaces
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: error.cc,v 1.1 2002-11-27 13:05:41 forbrig Exp $
* $Id: error.cc,v 1.2 2002-11-27 13:20:04 forbrig Exp $
* \author Thomas Forbriger
* \date 27/11/2002
*
......@@ -19,7 +19,7 @@
#define TF_ERROR_CC_VERSION \
"TF_ERROR_CC V1.0 "
#define TF_ERROR_CC_CVSID \
"$Id: error.cc,v 1.1 2002-11-27 13:05:41 forbrig Exp $"
"$Id: error.cc,v 1.2 2002-11-27 13:20:04 forbrig Exp $"
#include <iostream>
#include <tfxx/error.h>
......@@ -30,26 +30,26 @@ using std::endl;
namespace tfxx {
namespace error {
// initialize and instantiate
//! initialize and instantiate
bool Exception::Mreport_on_construct=true;
// construct from nothing
//! construct from nothing
Exception::Exception():
Mmessage(NULL), Mfile(NULL), Mline(0), Mcondition(NULL)
{ if (Mreport_on_construct) { report(); } }
// construct with message
//! construct with message
Exception::Exception(const char* message):
Mmessage(message), Mfile(NULL), Mline(0), Mcondition(NULL)
{ if (Mreport_on_construct) { report(); } }
// construct with message and file info
//! construct with message and file info
Exception::Exception(const char* message,
const char* condition):
Mmessage(message), Mfile(NULL), Mline(0), Mcondition(condition)
{ if (Mreport_on_construct) { report(); } }
// construct with message and file info and condition
//! construct with message and file info and condition
Exception::Exception(const char* message,
const char* file,
const int& line,
......@@ -57,25 +57,25 @@ namespace error {
Mmessage(message), Mfile(file), Mline(line), Mcondition(condition)
{ if (Mreport_on_construct) { report(); } }
// switch on
//! switch on
void Exception::report_on_construct()
{
Mreport_on_construct=true;
}
// switch off
//! switch off
void Exception::dont_report_on_construct()
{
Mreport_on_construct=false;
}
// report
void Exception::base_report() const
//! report
void Exception::report() const
{
base_report();
}
// report
//! report
void Exception::base_report() const
{
cerr << "Exception report:" << endl;
......@@ -94,7 +94,7 @@ namespace error {
if (Mcondition!=NULL)
{
cerr << " by condition:" << endl
<< " " << Mcondition << endl;
<< " \"" << Mcondition << "\"" << endl;
}
}
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: error.h,v 1.1 2002-11-27 13:05:41 forbrig Exp $
* $Id: error.h,v 1.2 2002-11-27 13:20:04 forbrig Exp $
* \author Thomas Forbriger
* \date 27/11/2002
*
......@@ -23,25 +23,44 @@
#define TF_ERROR_H_VERSION \
"TF_ERROR_H V1.0 "
#define TF_ERROR_H_CVSID \
"$Id: error.h,v 1.1 2002-11-27 13:05:41 forbrig Exp $"
"$Id: error.h,v 1.2 2002-11-27 13:20:04 forbrig Exp $"
namespace tfxx {
/*! \defgroup group_error Error handling module
*/
/*! \brief Error handline
*
* \ingroup group_error
* You may find the exception base class here.
*/
namespace error {
/*! \brief Base class for exceptions
*
* This is an exception base class. It holds some information about the
* reason for throwing the exception. The information is printed to cerr
* through function report(). This function may be overloaded by a derived
* type. But its functionality is still accessible through base_report().
*
* The standard behaviour is to print ou the message during object
* initialization. If you don't like this, call dont_report_on_construct().
*
* \ingroup group_error
* \sa TFXX_Xassert
*/
class Exception
{
public:
//! Creates exception with no explaning comments
Exception();
//! Creates an exception with an explanation message
Exception(const char* message);
//! Creates an exception with message and failed assertion
Exception(const char* message,
const char* condition);
//! Create with message, failed assertion, and code position
Exception(const char* message,
const char* file,
const int& line,
......@@ -57,9 +76,13 @@ namespace error {
void base_report() const;
//! Shall we print to cerr at construction time?
static bool Mreport_on_construct;
//! pointer to message string
const char* Mmessage;
//! pointer to file name string
const char* Mfile;
//! pointer to line number in source file
const int& Mline;
//! pointer to assertion condition text string
const char* Mcondition;
}; // class exception
......@@ -72,8 +95,9 @@ namespace error {
// preprocessor macros
// ===================
/*! check an assertion and report by throwing an exception
/*! \brief Check an assertion and report by throwing an exception
*
* \ingroup group_error
* \param C assert condition
* \param M message of type char*
* \param E exception class to throw
......@@ -81,8 +105,9 @@ namespace error {
#define TFXX_Xassert(C,M,E) \
if (!(C)) { throw( E ( M , __FILE__, __LINE__, #C )); }
/*! check an assertion and report by throwing an exception
/*! \brief Check an assertion and report by throwing an exception
*
* \ingroup group_error
* \param C assert condition
* \param M message of type char*
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment