📄 errorhandling.cpp
字号:
#include "ErrorHandling.h"
#include <sstream>
using namespace std;
namespace AudioEngine {
bool ThrowCError(HRESULT hr, std::string err, std::string filename, int line)
{
CError e(hr, err, filename, line);
string displaystr = e.GetMessageBoxString();
displaystr += "Press ABORT to end the program, RETRY to debug, IGNORE to throw the error.";
int result = MessageBox(NULL, displaystr.c_str(), "ErrorHandling.cpp", MB_ABORTRETRYIGNORE | MB_ICONSTOP);
switch(result) {
case IDABORT: // end the program immediately
exit(-1); // could also use abort() here
case IDRETRY: // break into the debugger
return(false); // let the #define do this so we stop on the actual errant line
case IDIGNORE: // continue as usual (throw the error)
throw(e);
}
return(true); // just to avoid compiler warnings
}
string CError::GetMessageBoxString()
{
stringstream str;
str << "An error has occured in this program." << endl << endl <<
"Error: " << GetError() << endl <<
"File: " << GetFile() << endl <<
"Line: " << GetLine() << endl;
if (GetReason().size()) {
str << "Reason: " << GetReason() << endl;
}
str << endl;
return(str.str());
}
}; // namespace
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -