/* libzz
*
* This program is distributed under the GNU General Public License, version 2.
* A copy of this license is included with this source.
*
* Copyright 2000-2006, Toni Thomsson <toni@tonjac.org>
*/
#ifndef zz_exception_h
#define zz_exception_h
#include <zz_string.h>
#include <zz_error.h>
#include <zz_export.h>
#ifndef _LAF
// Description: Macro för radnummer + filnamn
#define _LAF __LINE__, __FILE__
#endif
#define ZZ_THROW( buff, lf, code, msg ) { if( buff ) delete buff; throw CzzException( lf, code, msg ); }
/**
Base exception
@author Toni Thomsson, toni@tonjac.org
*/
class ZZ_API CzzException
{
public:
/** Copy constructor */
CzzException( const CzzException& exceptionSrc );
/**
Create an exception
@param lineNumber Line number in sourcecode file, use __LINE__
@param fileName Sourcecode file, use __FILE__
@param callId Id, can be empty
@param code Error code
@param reason Error text
*/
CzzException( int lineNumber,
CzzString fileName,
CzzString callId,
int code,
CzzString reason );
/**
Create an exception
@param lineNumber Line number in sourcecode file, use __LINE__
@param fileName Sourcecode file, use __FILE__
@param code Error code
@param reason Error text
*/
CzzException( int lineNumber, // IN, radnummer
CzzString fileName, // IN, filnamn
int code, // IN, felkod
CzzString reason // IN, feltext
);
virtual ~CzzException();
/** Time of occurance */
time_t GetOccuranceTime( void ) const;
/** Error stack */
static CzzErrorHistory* GetErrorHistory( void );
/** Error text */
CzzString GetReason( void ) const;
/** Id */
CzzString GetCallId( void ) const;
/** File name */
CzzString GetFileName( void ) const;
/** Row number */
int GetLineNumber( void ) const;
/** Error code */
int GetCode( void ) const;
protected:
/** Store error on error stack */
void StoreInHistory( void );
/** Error stack */
static CzzErrorHistory* m_ErrorHistory;
/** Time of occurance */
const time_t m_OccuranceTime;
/** Id */
CzzString m_CallId;
/** Error text */
CzzString m_Reason;
/** Filename */
CzzString m_FileName;
/** Row number */
int m_LineNumber;
/** Error code */
int m_Code;
private:
void CheckRemoveHistory( void );
};
#endif