/**
 * EH_Exception.cpp
 *
 * Copyright by AirDream Co., Ltd. 2010-2011 All right reserved
 *
 * Description:
 * Created on:2011-8-23
 * Modified on:2011-8-23
 *
 */

#include <EH_Exception.h>

EH_Exception::EH_Exception(const char* error_msg, 
                           const char* file_name,
                           unsigned int line_no,
                           const char* function_name,
                           int error_code) :
                           m_strErrorMsg(error_msg),
                           m_strFileName(file_name),
                           m_strFunctionName(function_name),
                           m_uiLineNo(line_no),
                           m_nErrorCode(error_code) {

}

EH_Exception::~EH_Exception() throw () {

}

inline const char* EH_Exception::GetErrorMsg() const {
    return m_strErrorMsg.c_str();
}

inline unsigned int EH_Exception::GetLineNo() const {
    return m_uiLineNo;
}

inline const char* EH_Exception::GetFileName() const {
    return m_strFileName.c_str();
}

inline int EH_Exception::GetErrorCode() const {
    return m_nErrorCode;
}

inline const char* EH_Exception::GetFunctionName() const {
    return m_strFunctionName.c_str();
}

ostream& operator<<(ostream& arOstream, const EH_Exception& arException) {
    return arException.dump(arOstream);
}

ostream& EH_Exception::dump(ostream& arOstream) const {
    arOstream << "Exception";
    if (*GetErrorMsg() != '\0') {
        arOstream << ": " << what();
    }
    arOstream << " (" << GetFunctionName() << "()," << GetFileName() << ":"
              << GetLineNo() << ")" << endl;
    return arOstream;
}

