Extending Error Codes – to DirectX and Beyond.

$err,hr is quite useful as is, but it only knows how to interpret built-in error codes. Happily, there is an easy way to extend it, via a section in autoexp.

All it takes is adding lines of the form –

error_code_in_decimal = the_string_you_want_displayed .

For instance, paste the following code into your autoexp.dat to decode Direct3D errors:

[hresult]
;1234=my custom error code
...
; start copying from here:
2289436696=D3DERR_WRONGTEXTUREFORMAT
2289436697=D3DERR_UNSUPPORTEDCOLOROPERATION
2289436698=D3DERR_UNSUPPORTEDCOLORARG
2289436699=D3DERR_UNSUPPORTEDALPHAOPERATION
2289436700=D3DERR_UNSUPPORTEDALPHAARG
2289436701=D3DERR_TOOMANYOPERATIONS
2289436702=D3DERR_CONFLICTINGTEXTUREFILTER
2289436703=D3DERR_UNSUPPORTEDFACTORVALUE
2289436705=D3DERR_CONFLICTINGRENDERSTATE
2289436706=D3DERR_UNSUPPORTEDTEXTUREFILTER
2289436710=D3DERR_CONFLICTINGTEXTUREPALETTE
2289436711=D3DERR_DRIVERINTERNALERROR

2289436774=D3DERR_NOTFOUND
2289436775=D3DERR_MOREDATA
2289436776=D3DERR_DEVICELOST
2289436777=D3DERR_DEVICENOTRESET
2289436778=D3DERR_NOTAVAILABLE
2289435004= D3DERR_OUTOFVIDEOMEMORY
2289436779=D3DERR_INVALIDDEVICE
2289436780=D3DERR_INVALIDCALL
2289436781=D3DERR_DRIVERINVALIDCALL
2289435164=D3DERR_WASSTILLDRAWING
141953135=D3DOK_NOAUTOGEN

2289436784=D3DERR_DEVICEREMOVED
141953141=S_NOT_RESIDENT
141953142=S_RESIDENT_IN_SHARED_MEMORY
141953143=S_PRESENT_MODE_CHANGED
141953144=S_PRESENT_OCCLUDED
2289436788=D3DERR_DEVICEHUNG
;end copy.

These were adapted from macros defined d3d9.h.  Just this week I learnt you could do the same with HRESULT codes of the CLR, and of course you could do the same for your own custom error codes.

Advertisement
This entry was posted in Debugging, Visual Studio. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s