#ifndef COMMON_EXCEPTION_H_INCLUDED
#define COMMON_EXCEPTION_H_INCLUDED
/*****************************************************************************/
/* HEADER FILE */
/*****************************************************************************/
/*
$Archive: $
$Revision: $
$Date: $
$Author: $
Description: Declaration of the common exception class, the root class
for all exception types and the work horse for this system
of exceptions
TOOL And XML FORMS License
==========================
Except where otherwise noted, all of the documentation
and software included in the TOOL package is
copyrighted by Michael Swartzendruber.
Copyright (C) 2005 Michael John Swartzendruber.
All rights reserved.
Access to this code, whether intentional or accidental,
does NOT IMPLY any transfer of rights.
This software is provided "as-is," without any express
or implied warranty. In no event shall the author be held
liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for
any purpose, including commercial applications, and to
alter and redistribute it, provided that the following
conditions are met:
1. All redistributions of source code files must retain
all copyright notices that are currently in place,
and this list of conditions without modification.
2. The origin of this software must not be misrepresented;
you must not claim that you wrote the original software.
3. If you use this software in another product, an acknowledgment
in the product documentation would be appreciated but is
not required.
4. Modified versions in source or binary form must be plainly
marked as such, and must not be misrepresented as being
the original software.
sample usage:
try
{
// something
}
catch( CFileException* poFileEx )
{
// sample of eat and continue
//
m_poLogFile->LogException( poFileEx );
delete poFileEx;
}
catch( CSoftwareException* poSockEx )
{
// sample of putting a 'call stack' on an
// exception and continuing to propagate
// it up the call stack
//
poSockEx->Push( __FILE__,
"Where Am I NOW?",
__LINE__,
"What Am I DOING Here?" );
throw poSockEx;
}
*/
/*****************************************************************************/
#pragma warning( disable : 4267 )
#include "ExceptionInfo.h"
#include "ExceptionInfoDeque.h"
class CCommonException
{
public:
CCommonException( const char* pchFile,
const char* pchMethod,
const int iLine,
const char* pchErrorMsg = "",
const int iErrorCode = 0,
const char* pchSubID = "" );
virtual ~CCommonException(){;};
const int GetNumEntries( void ) const;
const CExceptionInfo& GetOriginalException( void ) const;
const CExceptionInfo& GetLatestException( void ) const;
const ExceptionInfoDeque& GetExceptions( void ) const;
const bool IsOK( void ) const;
virtual const char* GetID( void ) const;
void Push( const char* pchFile,
const char* pchMethod,
const int iLine,
const char* pchErrorMsg = "" );
void Push( const char* pchFile,
const char* pchMethod,
const int iLine,
const char* pchErrorMsg,
const int iErrorCode );
void ImportPrior( const CCommonException& roException );
protected:
CCommonException( const char* pchID,
const char* pchFile,
const char* pchMethod,
const int iLine,
const char* pchErrorMsg,
const int iErrorCode,
const char* pchSubID );
void Add( const char* pchID,
const char* pchFile,
const char* pchMethod,
const int iLine,
const char* pchErrorMsg,
const int iErrorCode,
const char* pchSubID );
ExceptionInfoDeque m_oExceptionInfoDeque;
bool m_bCompleteFlag;
const CExceptionInfo& SetDefaultErrorExceptionInfo( void ) const;
private:
CCommonException( void );
static const CCommonException StaticInitException;
};
inline const int CCommonException::GetNumEntries( void ) const
{
return m_oExceptionInfoDeque.size();
}
inline const CExceptionInfo& CCommonException::GetOriginalException( void ) const
{
if ( m_oExceptionInfoDeque.size() != 0 )
{
return( m_oExceptionInfoDeque.front() );
}
else
{
return( SetDefaultErrorExceptionInfo() );
}
}
inline const CExceptionInfo& CCommonException::GetLatestException( void ) const
{
if ( m_oExceptionInfoDeque.size() != 0 )
{
return( m_oExceptionInfoDeque.back() );
}
else
{
return( SetDefaultErrorExceptionInfo() );
}
}
inline const ExceptionInfoDeque& CCommonException::GetExceptions( void ) const
{
return( m_oExceptionInfoDeque );
}
inline const bool CCommonException::IsOK( void ) const
{
return( m_bCompleteFlag );
}
inline void CCommonException::Push( const char* pchFile,
const char* pchMethod,
const int iLine,
const char* pchErrorMsg )
{
Push( pchFile, pchMethod, iLine, pchErrorMsg, 0 );
}
#endif
/*****************************************************************************/
/* Check-in history */
/*
*$Log: $
*/
/*****************************************************************************/