Esempio n. 1
0
/**
 *  External function to handle errors in the EPUB3 library
 */
bool LauncherErrorHandler(const ePub3::error_details& err)
{
    const char * msg = err.message();
    wprintf(L"%s\n", msg);

    if (err.is_spec_error())
    {
        switch (err.severity())
        {
        case ePub3::ViolationSeverity::Critical:
        case ePub3::ViolationSeverity::Major: {

            if (!m_ignoreRemainingErrors)
            {
                int len = strlen(msg) + 1;
                wchar_t *w_msg = new wchar_t[len];
                memset(w_msg, 0, len);
                MultiByteToWideChar(CP_ACP, NULL, msg, -1, w_msg, len);

                int msgboxID = MessageBox(
                    NULL,
                    (LPCWSTR)w_msg,
                    (LPCWSTR)L"EPUB warning",
                    MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON1
                    );

                switch (msgboxID)
                {
                case IDCANCEL:
                    m_ignoreRemainingErrors = true;
                    break;
                case IDOK:
                    break;
                default:
                    break;
                }
            }

            break;
        }
        default:
            break;
        }
    }

    return true;
}
Esempio n. 2
0
static bool LauncherErrorHandler(const ePub3::error_details& err)
{
    const char * msg = err.message();

	bool isSevereEpubError = (err.is_spec_error()
			&& (err.severity() == ePub3::ViolationSeverity::Critical
			|| err.severity() == ePub3::ViolationSeverity::Major));

    LOGD("READIUM SDK ERROR HANDLER (%s): %s\n", isSevereEpubError ? "warning" : "info", msg);

    jstring jmessage = m_env->NewStringUTF(msg);
    jboolean b = javaEPub3_handleSdkError(m_env, jmessage, (jboolean)isSevereEpubError);
    m_env->DeleteLocalRef(jmessage);
    return (bool)b;
    
    // never throws an exception
    //return ePub3::DefaultErrorHandler(err);
}