win32/HResult: add MakeHResultError()
None of the current FormatHResultError() callers need the format string.
This commit is contained in:
@@ -31,7 +31,7 @@ public:
|
||||
COM() {
|
||||
if (HRESULT result = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
||||
FAILED(result)) {
|
||||
throw FormatHResultError(
|
||||
throw MakeHResultError(
|
||||
result,
|
||||
"Unable to initialize COM with COINIT_MULTITHREADED");
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
COM(bool) {
|
||||
if (HRESULT result = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
||||
FAILED(result)) {
|
||||
throw FormatHResultError(
|
||||
throw MakeHResultError(
|
||||
result,
|
||||
"Unable to initialize COM with COINIT_APARTMENTTHREADED");
|
||||
}
|
||||
|
@@ -85,7 +85,7 @@ public:
|
||||
::CoCreateInstance(class_id, unknown_outer, class_context,
|
||||
__uuidof(T), reinterpret_cast<void **>(&ptr));
|
||||
if (FAILED(result)) {
|
||||
throw FormatHResultError(result, "Unable to create instance");
|
||||
throw MakeHResultError(result, "Unable to create instance");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -74,6 +74,13 @@ static inline const std::error_category &hresult_category() noexcept {
|
||||
return hresult_category_instance;
|
||||
}
|
||||
|
||||
inline std::system_error
|
||||
MakeHResultError(HRESULT result, const char *msg) noexcept
|
||||
{
|
||||
return std::system_error(std::error_code(result, hresult_category()),
|
||||
msg);
|
||||
}
|
||||
|
||||
gcc_printf(2, 3) std::system_error
|
||||
FormatHResultError(HRESULT result, const char *fmt, ...) noexcept;
|
||||
|
||||
|
Reference in New Issue
Block a user