MCPcopy Create free account
hub / github.com/OpenCppCoverage/OpenCppCoverage / GetExceptionStrFromCode

Method GetExceptionStrFromCode

CppCoverage/ExceptionHandler.cpp:124–151  ·  view source on GitHub ↗

-------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

122
123 //-------------------------------------------------------------------------
124 std::wstring ExceptionHandler::GetExceptionStrFromCode(DWORD exceptionCode) const
125 {
126 auto it = exceptionCode_.find(exceptionCode);
127
128 if (it != exceptionCode_.end())
129 return it->second;
130
131 LPTSTR message = nullptr;
132 HMODULE ntDllModule = LoadLibrary(L"NTDLL.DLL");
133 Tools::ScopedAction closeLibrary{ [=](){ FreeLibrary(ntDllModule); } };
134
135 FormatMessage(
136 FORMAT_MESSAGE_ALLOCATE_BUFFER |
137 FORMAT_MESSAGE_FROM_SYSTEM |
138 FORMAT_MESSAGE_FROM_HMODULE,
139 ntDllModule,
140 exceptionCode,
141 MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
142 reinterpret_cast<LPTSTR>(&message),
143 0,
144 nullptr);
145 Tools::ScopedAction freeMessage{ [=](){ LocalFree(message); } };
146
147 if (message)
148 return message;
149
150 return ExceptionUnknown;
151 }
152}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected