#include "StdAfx.h"
#include "DirectXException.h"
namespace Sunlight
{
namespace DirectX
{
DirectXException::DirectXException(String *pSource, HRESULT nCode) :
Exception(String::Format(S"DirectX method {0} threw exception \"{1}\".", pSource, GetExceptionString(nCode)))
{
Source = pSource;
HResult = nCode;
}
String *DirectXException::GetExceptionString(HRESULT h)
{
TCHAR sError[256];
if (FAILED(D3DXGetErrorString(h, sError, 256)) || (sError[0] == 0))
return String::Format(S"Unknown exception 0x{1:x8}", __box(h));
return new String(sError);
}
DirectXException::~DirectXException()
{
}
}
}