diff options
Diffstat (limited to 'c/win.cpp')
-rw-r--r-- | c/win.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -1,7 +1,33 @@ #include <utility> +#include <SWI-Prolog.h> #include <windows.h> +#include "pl.h" +#include "util.h" #include "win.h" +#include "wcharptr.h" + +void ShowException(const wchar_t* const fmt, const wchar_t* const title, const UINT uType) noexcept +{ + const wchar_t* what = L"an exception"; + WcharPtr why; + + try { + std::rethrow_exception(std::current_exception()); + } catch (const term_t& t) { + what = L"a Prolog exception"; + try { why = PlString(t); } catch (...) {} + } catch (const Win32Error& e) { + what = L"a Windows error"; + try { why = WcharPtr::Copy(e.What()); } catch (...) {} + } catch (const std::exception& e) { + try { why = WcharPtr::FromNarrow(e.what()); } catch (...) {} + } catch (...) {} + + wchar_t msg[512]; + Swprintf(msg, fmt, what, static_cast<wchar_t*>(why)); + EBMessageBox(msg, title, uType); +} void WithNextWindow(void (*proc)(HWND)) { |