< prev index next >

src/jdk.incubator.jpackage/windows/native/libjpackage/WinErrorHandling.h

Print this page

        

@@ -21,14 +21,29 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
-#include <windows.h>
 
-extern "C" {
+#ifndef WinErrorHandling_h
+#define WinErrorHandling_h
 
-    BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
-            LPVOID lpvReserved) {
-        return true;
-    }
-}
\ No newline at end of file
+
+#include "ErrorHandling.h"
+
+
+class SysError : public std::runtime_error {
+public:
+    SysError(const tstrings::any& msg, const void* caller,
+            DWORD errorCode=GetLastError(), const char* label="System error");
+
+    // returns string "system error <errCode> (error_description)"
+    // in UNICODE is not defined, the string returned is utf8-encoded
+    static std::wstring getSysErrorMessage(DWORD errCode = GetLastError(),
+            HMODULE moduleHandle = NULL);
+
+    // returns string "COM error 0x<hr> (error_description)"
+    // in UNICODE is not defined, the string returned is utf8-encoded
+    static std::wstring getComErrorMessage(HRESULT hr);
+};
+
+#endif // #ifndef WinErrorHandling_h
< prev index next >