// Graphics.cpp
#include "Graphics.h"
#include "dxerr.h"
#include <sstream>
std::string Graphics::HrException::GetErrorString() const noexcept
{
return DXGetErrorString(hr);
}
std::string Graphics::HrException::GetErrorDescription() const noexcept
{
char buf[512];
DXGetErrorDescription(hr, buf, sizeof(buf));
return buf;
}
DXGetErrorString and DXGetErrorDescription give this error respectively:
1 unresolved external symbol DXGetErrorStringA referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Graphics::HrException::GetErrorString(void)const " (?GetErrorString@HrException@Graphics@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
2 unresolved external symbol DXGetErrorDescriptionA referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Graphics::HrException::GetErrorDescription(void)const " (?GetErrorDescription@HrException@Graphics@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
// Graphics.h
#pragma once
#include <d3d11.h>
#include <string>
class Graphics
{
public:
class Exception : public ExceptionHandling
{
using ExceptionHandling::ExceptionHandling;
};
class HrException : public Exception
{
public:
HrException(int line, const char* file, HRESULT hr) noexcept;
const char* what() const noexcept override;
const char* GetType() const noexcept override;
HRESULT GetErrorCode() const noexcept;
std::string GetErrorString() const noexcept;
std::string GetErrorDescription() const noexcept;
private:
HRESULT hr;
};
class DeviceRemovedException : public HrException
{
using HrException::HrException;
public:
const char* GetType() const noexcept override;
};
}
I don't know if this helps but I am using dxerr (with DXGetErrorString.inl, DXGetErrorDescription.inl and DXTrace.inl) for error handling, i don't know if this is the best way as I am not an expert in this field.