Exceptions are now derived from std::exception and tell source code file and line.
This commit is contained in:
@@ -18,8 +18,27 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "pokerthexception.h"
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
PokerTHException::PokerTHException(const char *sourcefile, int sourceline, int errorId, int osErrorCode)
|
||||
: m_errorId(errorId), m_osErrorCode(osErrorCode)
|
||||
{
|
||||
ostringstream msgStream;
|
||||
msgStream << sourcefile << " (" << sourceline << "): Error " << errorId;
|
||||
if (osErrorCode)
|
||||
msgStream << " (system error " << osErrorCode << ")";
|
||||
m_msg = msgStream.str();
|
||||
}
|
||||
|
||||
PokerTHException::~PokerTHException()
|
||||
{
|
||||
}
|
||||
|
||||
const char *
|
||||
PokerTHException::what() const
|
||||
{
|
||||
return m_msg.c_str();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,21 +21,26 @@
|
||||
#ifndef _POKERTHEXCEPTION_H_
|
||||
#define _POKERTHEXCEPTION_H_
|
||||
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
class PokerTHException
|
||||
class PokerTHException : public std::exception
|
||||
{
|
||||
public:
|
||||
|
||||
PokerTHException(int errorId, int osErrorCode)
|
||||
: m_errorId(errorId), m_osErrorCode(osErrorCode) {}
|
||||
PokerTHException(const char *sourcefile, int sourceline, int errorId, int osErrorCode);
|
||||
virtual ~PokerTHException();
|
||||
|
||||
int GetErrorId() const {return m_errorId;}
|
||||
int GetOsErrorCode() const {return m_osErrorCode;}
|
||||
|
||||
virtual const char *what() const;
|
||||
|
||||
private:
|
||||
int m_errorId;
|
||||
int m_osErrorCode;
|
||||
|
||||
std::string m_msg;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user