From 56a9a25192c31fde2bb3bbb7906f0220285227ab Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Mon, 24 Feb 2020 11:57:02 +0000 Subject: Windows: Add nserror reporting function Signed-off-by: Daniel Silverstone --- frontends/windows/gui.c | 14 ++++++++++++++ frontends/windows/gui.h | 10 ++++++++++ 2 files changed, 24 insertions(+) (limited to 'frontends') diff --git a/frontends/windows/gui.c b/frontends/windows/gui.c index fdfafcf42..9a2c13b23 100644 --- a/frontends/windows/gui.c +++ b/frontends/windows/gui.c @@ -182,3 +182,17 @@ nserror win32_warning(const char *warning, const char *detail) } +/* exported function documented in windows/gui.h */ +nserror +win32_report_nserror(nserror error, const char *detail) +{ + size_t len = 1 + + strlen(messages_get_errorcode(error)) + + ((detail != 0) ? strlen(detail) : 0); + char message[len]; + snprintf(message, len, messages_get_errorcode(error), detail); + MessageBox(NULL, message, "Warning", MB_ICONWARNING); + + return NSERROR_OK; +} + diff --git a/frontends/windows/gui.h b/frontends/windows/gui.h index 0633c93e8..957280ae4 100644 --- a/frontends/windows/gui.h +++ b/frontends/windows/gui.h @@ -67,6 +67,16 @@ void win32_set_quit(bool q); */ nserror win32_warning(const char *warning, const char *detail); +/** + * Warn the user of an unexpected nserror. + * + * \param[in] error The nserror to report + * \param[in] detail Additional text to be displayed or NULL. + * \return NSERROR_OK on success or error code if there was a + * faliure displaying the message to the user. + */ +nserror win32_report_nserror(nserror error, const char *detail); + /** * add a modeless dialog to the special handling list */ -- cgit v1.2.3