Windows: Add nserror reporting function

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
Daniel Silverstone 2020-02-24 11:57:02 +00:00
parent a970572fc9
commit 56a9a25192
No known key found for this signature in database
GPG Key ID: C30DF439F2987D74
2 changed files with 24 additions and 0 deletions

View File

@ -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;
}

View File

@ -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
*/