#include "stdafx.h"
#include "nexception.h"



#include "namespace_start.h"



///
///コンストラクタ
///
Exception::Exception(const NString  &errMessage,UInt in_line,const NString &in_fileName,const NString &in_function,HRESULT hResult):

errMessage(errMessage),
line(in_line),
fileName(in_fileName),
function(in_function),
std::runtime_error(""),
osErrorCode(hResult)
{}
		
		
///
///エラー文言取得
///
const NString &Exception::GetErrorMessage()const{

	return errMessage;
}


///
///エラー発生行取得
///
UInt Exception::getLineNo()const{

	return line;
}

///
///エラー発生ファイル名取得
///
const NString &Exception::getFileName()const{

	return fileName;
}


///
///エラー発生関数名を取得
///
const NString &Exception::getFunctionName()const{

	return function;
}

Bool Exception:: Report(){

	NChar file[_MAX_PATH];
	NChar ext[_MAX_PATH];
	_wsplitpath(getFileName().c_str(),(NChar*)NULL,(NChar*)NULL,file,ext);
	
	
	
	BugTransfer bug;
	bug.sourcefile += file;
	bug.sourcefile += ext;

	
	bug.summary = GetErrorMessage();
	bug.function = getFunctionName();
	bug.line = boost::lexical_cast<NString>(getLineNo());
	bug.windowsErrorCode = boost::lexical_cast<NString>(osErrorCode);
	GetWindowsErrorMessage(bug.windowsErrorMessage,osErrorCode);

	auto &reporter = CBugReporter::GetInstance();
	reporter.Report(bug);

	
	return false;

}



#include "namespace_end.h"
