| 1 |
// SSException.h: interface for the SSException class. |
|---|
| 2 |
// |
|---|
| 3 |
////////////////////////////////////////////////////////////////////// |
|---|
| 4 |
|
|---|
| 5 |
#if !defined(AFX_SSEXCEPTION_H__56E9DD10_4947_45AB_A7C5_F732DE0538A5__INCLUDED_) |
|---|
| 6 |
#define AFX_SSEXCEPTION_H__56E9DD10_4947_45AB_A7C5_F732DE0538A5__INCLUDED_ |
|---|
| 7 |
|
|---|
| 8 |
#if _MSC_VER > 1000 |
|---|
| 9 |
#pragma once |
|---|
| 10 |
#endif // _MSC_VER > 1000 |
|---|
| 11 |
|
|---|
| 12 |
#include <sstream> |
|---|
| 13 |
#include "SSRecord.h" |
|---|
| 14 |
|
|---|
| 15 |
#if !defined(_RAISE) |
|---|
| 16 |
# define _RAISE(e) throw e |
|---|
| 17 |
#endif |
|---|
| 18 |
|
|---|
| 19 |
//--------------------------------------------------------------------------- |
|---|
| 20 |
class SSException : public std::exception |
|---|
| 21 |
{ |
|---|
| 22 |
public: |
|---|
| 23 |
SSException(const std::string& str) |
|---|
| 24 |
: exception (), m_Str (str) |
|---|
| 25 |
{ |
|---|
| 26 |
} |
|---|
| 27 |
virtual ~SSException() throw () |
|---|
| 28 |
{} |
|---|
| 29 |
virtual const char *what() const throw () |
|---|
| 30 |
{return (m_Str.c_str()); } |
|---|
| 31 |
protected: |
|---|
| 32 |
virtual void _Doraise() const |
|---|
| 33 |
{_RAISE(*this); } |
|---|
| 34 |
|
|---|
| 35 |
std::string m_Str; |
|---|
| 36 |
}; |
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
//--------------------------------------------------------------------------- |
|---|
| 41 |
class SSRecordException : public SSException |
|---|
| 42 |
{ |
|---|
| 43 |
public: |
|---|
| 44 |
SSRecordException(const std::string& str) |
|---|
| 45 |
: SSException (str) |
|---|
| 46 |
{ |
|---|
| 47 |
} |
|---|
| 48 |
protected: |
|---|
| 49 |
virtual void _Doraise() const |
|---|
| 50 |
{_RAISE(*this); } |
|---|
| 51 |
private: |
|---|
| 52 |
}; |
|---|
| 53 |
|
|---|
| 54 |
//--------------------------------------------------------------------------- |
|---|
| 55 |
#include <strstream> |
|---|
| 56 |
class SSUnknownActionException : public SSException |
|---|
| 57 |
{ |
|---|
| 58 |
public: |
|---|
| 59 |
SSUnknownActionException (short action, SSRecordPtr record) |
|---|
| 60 |
: m_Action (action), m_record (record), SSException ("unknown action") |
|---|
| 61 |
{ |
|---|
| 62 |
} |
|---|
| 63 |
virtual ~SSUnknownActionException() throw () |
|---|
| 64 |
{} |
|---|
| 65 |
virtual const char *what() const throw () |
|---|
| 66 |
{ |
|---|
| 67 |
std::ostringstream stream; |
|---|
| 68 |
stream << m_Str << " " << m_Action << " at offset 0x" << std::hex << m_record->GetOffset(); |
|---|
| 69 |
m_Message = stream.str(); |
|---|
| 70 |
return (m_Message.c_str ()); |
|---|
| 71 |
} |
|---|
| 72 |
private: |
|---|
| 73 |
short m_Action; |
|---|
| 74 |
mutable std::string m_Message; |
|---|
| 75 |
SSRecordPtr m_record; |
|---|
| 76 |
}; |
|---|
| 77 |
|
|---|
| 78 |
#endif // !defined(AFX_SSEXCEPTION_H__56E9DD10_4947_45AB_A7C5_F732DE0538A5__INCLUDED_) |
|---|