Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Clark Lin
hw3d
Commits
f2326a37
Commit
f2326a37
authored
Jan 27, 2019
by
chili
Browse files
info only exception
parent
caca4839
Changes
2
Hide whitespace changes
Inline
Side-by-side
hw3d/Graphics.cpp
View file @
f2326a37
...
@@ -14,10 +14,12 @@ namespace wrl = Microsoft::WRL;
...
@@ -14,10 +14,12 @@ namespace wrl = Microsoft::WRL;
#define GFX_EXCEPT(hr) Graphics::HrException( __LINE__,__FILE__,(hr),infoManager.GetMessages() )
#define GFX_EXCEPT(hr) Graphics::HrException( __LINE__,__FILE__,(hr),infoManager.GetMessages() )
#define GFX_THROW_INFO(hrcall) infoManager.Set(); if( FAILED( hr = (hrcall) ) ) throw GFX_EXCEPT(hr)
#define GFX_THROW_INFO(hrcall) infoManager.Set(); if( FAILED( hr = (hrcall) ) ) throw GFX_EXCEPT(hr)
#define GFX_DEVICE_REMOVED_EXCEPT(hr) Graphics::DeviceRemovedException( __LINE__,__FILE__,(hr),infoManager.GetMessages() )
#define GFX_DEVICE_REMOVED_EXCEPT(hr) Graphics::DeviceRemovedException( __LINE__,__FILE__,(hr),infoManager.GetMessages() )
#define GFX_THROW_INFO_ONLY(call) infoManager.Set(); (call); {auto v = infoManager.GetMessages(); if(!v.empty()) {throw Graphics::InfoException( __LINE__,__FILE__,v);}}
#else
#else
#define GFX_EXCEPT(hr) Graphics::HrException( __LINE__,__FILE__,(hr) )
#define GFX_EXCEPT(hr) Graphics::HrException( __LINE__,__FILE__,(hr) )
#define GFX_THROW_INFO(hrcall) GFX_THROW_NOINFO(hrcall)
#define GFX_THROW_INFO(hrcall) GFX_THROW_NOINFO(hrcall)
#define GFX_DEVICE_REMOVED_EXCEPT(hr) Graphics::DeviceRemovedException( __LINE__,__FILE__,(hr) )
#define GFX_DEVICE_REMOVED_EXCEPT(hr) Graphics::DeviceRemovedException( __LINE__,__FILE__,(hr) )
#define GFX_THROW_INFO_ONLY(call) (call)
#endif
#endif
...
@@ -129,7 +131,7 @@ void Graphics::DrawTestTriangle()
...
@@ -129,7 +131,7 @@ void Graphics::DrawTestTriangle()
const
UINT
offset
=
0u
;
const
UINT
offset
=
0u
;
pContext
->
IASetVertexBuffers
(
0u
,
1u
,
&
pVertexBuffer
,
&
stride
,
&
offset
);
pContext
->
IASetVertexBuffers
(
0u
,
1u
,
&
pVertexBuffer
,
&
stride
,
&
offset
);
pContext
->
Draw
(
3u
,
0u
);
GFX_THROW_INFO_ONLY
(
pContext
->
Draw
(
3u
,
0u
)
);
}
}
...
@@ -201,3 +203,40 @@ const char* Graphics::DeviceRemovedException::GetType() const noexcept
...
@@ -201,3 +203,40 @@ const char* Graphics::DeviceRemovedException::GetType() const noexcept
{
{
return
"Chili Graphics Exception [Device Removed] (DXGI_ERROR_DEVICE_REMOVED)"
;
return
"Chili Graphics Exception [Device Removed] (DXGI_ERROR_DEVICE_REMOVED)"
;
}
}
Graphics
::
InfoException
::
InfoException
(
int
line
,
const
char
*
file
,
std
::
vector
<
std
::
string
>
infoMsgs
)
noexcept
:
Exception
(
line
,
file
)
{
// join all info messages with newlines into single string
for
(
const
auto
&
m
:
infoMsgs
)
{
info
+=
m
;
info
.
push_back
(
'\n'
);
}
// remove final newline if exists
if
(
!
info
.
empty
()
)
{
info
.
pop_back
();
}
}
const
char
*
Graphics
::
InfoException
::
what
()
const
noexcept
{
std
::
ostringstream
oss
;
oss
<<
GetType
()
<<
std
::
endl
<<
"
\n
[Error Info]
\n
"
<<
GetErrorInfo
()
<<
std
::
endl
<<
std
::
endl
;
oss
<<
GetOriginString
();
whatBuffer
=
oss
.
str
();
return
whatBuffer
.
c_str
();
}
const
char
*
Graphics
::
InfoException
::
GetType
()
const
noexcept
{
return
"Chili Graphics Info Exception"
;
}
std
::
string
Graphics
::
InfoException
::
GetErrorInfo
()
const
noexcept
{
return
info
;
}
hw3d/Graphics.h
View file @
f2326a37
...
@@ -27,6 +27,16 @@ public:
...
@@ -27,6 +27,16 @@ public:
HRESULT
hr
;
HRESULT
hr
;
std
::
string
info
;
std
::
string
info
;
};
};
class
InfoException
:
public
Exception
{
public:
InfoException
(
int
line
,
const
char
*
file
,
std
::
vector
<
std
::
string
>
infoMsgs
)
noexcept
;
const
char
*
what
()
const
noexcept
override
;
const
char
*
GetType
()
const
noexcept
override
;
std
::
string
GetErrorInfo
()
const
noexcept
;
private:
std
::
string
info
;
};
class
DeviceRemovedException
:
public
HrException
class
DeviceRemovedException
:
public
HrException
{
{
using
HrException
::
HrException
;
using
HrException
::
HrException
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment