/**
 * EH_Exception.h
 *
 */

#ifndef EH_EXCEPTION_H_
#define EH_EXCEPTION_H_

#include <string>
#include <exception>
#include <iostream>

using namespace std;

class EH_Exception : public exception {
public:
    EH_Exception(const char* error_msg, 
                 const char* file_name,
                 unsigned int line_no,
                 const char* function_name,
                 int error_code = 0);
    virtual ~EH_Exception() throw ();

    const char* GetErrorMsg() const;
    virtual const char* what() const throw () {
        return m_strErrorMsg.c_str();
    }
    unsigned int GetLineNo() const;
    const char* GetFileName() const;
    const char* GetFunctionName() const;
    int GetErrorCode() const;
    virtual ostream& dump(ostream& arOstream) const;
    friend ostream& operator<<(ostream& arOstream,
                               const EH_Exception& arException);

private:
    string       m_strErrorMsg;
    string       m_strFileName;
    string       m_strFunctionName;
    unsigned int m_uiLineNo;
    int          m_nErrorCode;

};

#define EH_EXCEPTION(msg) EH_Exception(msg, __FILE__, __LINE__, __func__)
#define EH_EXCEPTION_ERR(msg) EH_Exception(msg, __FILE__, __LINE__, __func__, err)

#endif /* EH_EXCEPTION_H_ */
