Creating custom HRESULT
has been covered here
Creating your own HRESULT?
Solution to above question is fine for c++ native clients, they can use the returned HRESULT
to FormatMessage()
and get error string, what about C# and JavaScript client? For discussion's sake let us forget FormatMessage()
via PInvoke.
e.g. if a COM function returns E_ACCESSDENIED
and C# client will receive it via nicely packaged exception, complete with error string and symbolic name(E_ACCESSDENIED
)
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
It is understood system error codes have been mapped to .Net exceptions.
Questions is how to return an message compiler generated custom error codes packaged in HRESULT
?
Is MAKE_HRESULT
the answer?