diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-12-08 23:08:32 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-12-08 23:08:32 +0000 |
| commit | 65055be458fb971228b4121a0009b820de6cd288 (patch) | |
| tree | 4712f6572e67fd395cde6c7d8fef6ced216a02f3 /Graphics/GraphicsEngineD3DBase | |
| parent | Updated run_test.bat to capture error in any of the test scripts (diff) | |
| download | DiligentCore-65055be458fb971228b4121a0009b820de6cd288.tar.gz DiligentCore-65055be458fb971228b4121a0009b820de6cd288.zip | |
appveyor: updated to use VS2019 image
Diffstat (limited to 'Graphics/GraphicsEngineD3DBase')
| -rw-r--r-- | Graphics/GraphicsEngineD3DBase/include/D3DErrors.h | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/Graphics/GraphicsEngineD3DBase/include/D3DErrors.h b/Graphics/GraphicsEngineD3DBase/include/D3DErrors.h index fdc3689f..66a51d87 100644 --- a/Graphics/GraphicsEngineD3DBase/include/D3DErrors.h +++ b/Graphics/GraphicsEngineD3DBase/include/D3DErrors.h @@ -23,6 +23,8 @@ #pragma once +#include <string.h> + #include "Errors.h" /// \file @@ -37,7 +39,7 @@ class ComErrorDesc public: ComErrorDesc(HRESULT hr) { - FormatMessageA( + auto NumCharsWritten = FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, hr, @@ -45,13 +47,21 @@ public: m_Msg, _countof(m_Msg), NULL); - auto nLen = strlen(m_Msg); - if (nLen > 1 && m_Msg[nLen - 1] == '\n') + + if (NumCharsWritten == 0) + { + strcpy_s(m_Msg, _countof(m_Msg), "Unknown error"); + } + else { - m_Msg[nLen - 1] = 0; - if (m_Msg[nLen - 2] == '\r') + auto nLen = strlen(m_Msg); + if (nLen > 1 && m_Msg[nLen - 1] == '\n') { - m_Msg[nLen - 2] = 0; + m_Msg[nLen - 1] = 0; + if (m_Msg[nLen - 2] == '\r') + { + m_Msg[nLen - 2] = 0; + } } } } |
