Make exception error more clear

Close #5212
This commit is contained in:
Rajendra Singh 2019-01-08 22:42:42 +05:30 committed by Don HO
parent 0f936707a2
commit 694415f8af
5 changed files with 52 additions and 22 deletions

View File

@ -259,7 +259,7 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath)
}
catch (std::exception& e)
{
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
pluginExceptionAlert(pluginFileName, e);
return -1;
}
catch (generic_string s)
@ -537,7 +537,7 @@ void PluginsManager::runPluginCommand(const TCHAR *pluginName, int commandID)
}
catch (std::exception& e)
{
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
pluginExceptionAlert(_pluginsCommands[i]._pluginName.c_str(), e);
}
catch (...)
{
@ -567,7 +567,7 @@ void PluginsManager::notify(size_t indexPluginInfo, const SCNotification *notifi
}
catch (std::exception& e)
{
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
pluginExceptionAlert(_pluginInfos[indexPluginInfo]->_moduleName.c_str(), e);
}
catch (...)
{
@ -605,7 +605,7 @@ void PluginsManager::relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam
}
catch (std::exception& e)
{
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
pluginExceptionAlert(_pluginInfos[i]->_moduleName.c_str(), e);
}
catch (...)
{
@ -636,7 +636,7 @@ bool PluginsManager::relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lPa
}
catch (std::exception& e)
{
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
pluginExceptionAlert(_pluginInfos[i]->_moduleName.c_str(), e);
}
catch (...)
{

View File

@ -148,6 +148,16 @@ private:
::MessageBox(NULL, msg.c_str(), TEXT("Plugin Crash"), MB_OK|MB_ICONSTOP);
}
void pluginExceptionAlert(const TCHAR *pluginName, const std::exception& e)
{
generic_string msg = TEXT("An exception occurred due to plugin: ");
msg += pluginName;
msg += TEXT("\r\n\r\nException reason: ");
msg += s2ws(e.what());
::MessageBox(NULL, msg.c_str(), TEXT("Plugin Exception"), MB_OK);
}
bool isInLoadedDlls(const TCHAR *fn) const
{
for (size_t i = 0; i < _loadedDlls.size(); ++i)

View File

@ -175,17 +175,27 @@ TCHAR* FileDialog::doOpenSingleFileDlg()
}
TCHAR *fn = NULL;
try {
fn = ::GetOpenFileName(&_ofn)?_fileName:NULL;
try
{
fn = ::GetOpenFileName(&_ofn) ? _fileName : NULL;
if (params->getNppGUI()._openSaveDir == dir_last)
{
::GetCurrentDirectory(MAX_PATH, dir);
params->setWorkingDir(dir);
}
} catch(std::exception& e) {
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} catch(...) {
}
catch (std::exception& e)
{
generic_string msg = TEXT("An exception occurred while opening file: ");
msg += _fileName;
msg += TEXT("\r\n\r\nException reason: ");
msg += s2ws(e.what());
::MessageBox(NULL, msg.c_str(), TEXT("File Open Exception"), MB_OK);
}
catch (...)
{
::MessageBox(NULL, TEXT("doOpenSingleFileDlg crashes!!!"), TEXT(""), MB_OK);
}
@ -268,16 +278,26 @@ TCHAR * FileDialog::doSaveDlg()
}
TCHAR *fn = NULL;
try {
fn = ::GetSaveFileName(&_ofn)?_fileName:NULL;
try
{
fn = ::GetSaveFileName(&_ofn) ? _fileName : NULL;
if (params->getNppGUI()._openSaveDir == dir_last)
{
::GetCurrentDirectory(MAX_PATH, dir);
params->setWorkingDir(dir);
}
} catch(std::exception& e) {
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} catch(...) {
}
catch (std::exception& e)
{
generic_string msg = TEXT("An exception occurred while saving file: ");
msg += _fileName;
msg += TEXT("\r\n\r\nException reason: ");
msg += s2ws(e.what());
::MessageBox(NULL, msg.c_str(), TEXT("File Save Exception"), MB_OK);
}
catch (...)
{
::MessageBox(NULL, TEXT("GetSaveFileName crashes!!!"), TEXT(""), MB_OK);
}

View File

@ -88,8 +88,8 @@ public:
};
protected:
HIMAGELIST _hImaLst;
WNDPROC _defaultProc;
HIMAGELIST _hImaLst = nullptr;
WNDPROC _defaultProc = nullptr;
LRESULT runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK staticProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {

View File

@ -277,7 +277,7 @@ public:
// Theo - Removed Tracing
protected:
WINRECT* m_map; // THE window map
WINRECT* m_map = nullptr; // THE window map
int CountWindows();
BOOL SendGetSizeInfo(SIZEINFO& szi, HWND hWnd, UINT nID);