Fix static analyzer issue "An exception should be caught by reference"

V746 Object slicing. An exception should be caught by reference rather than by value. filedialog.cpp 183
V746 Object slicing. An exception should be caught by reference rather than by value. nppbigswitch.cpp 110
V746 Object slicing. An exception should be caught by reference rather than by value. pluginsmanager.cpp 259
This commit is contained in:
Oleksandr Redko 2017-10-29 17:57:06 +02:00
parent 9181f70d47
commit bdcc386a3a
3 changed files with 9 additions and 9 deletions

View File

@ -256,7 +256,7 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
_pluginInfos.push_back(pi); _pluginInfos.push_back(pi);
return static_cast<int32_t>(_pluginInfos.size() - 1); return static_cast<int32_t>(_pluginInfos.size() - 1);
} }
catch (std::exception e) catch (std::exception& e)
{ {
::MessageBoxA(NULL, e.what(), "Exception", MB_OK); ::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
return -1; return -1;
@ -519,7 +519,7 @@ void PluginsManager::runPluginCommand(size_t i)
{ {
_pluginsCommands[i]._pFunc(); _pluginsCommands[i]._pFunc();
} }
catch (std::exception e) catch (std::exception& e)
{ {
::MessageBoxA(NULL, e.what(), "PluginsManager::runPluginCommand Exception", MB_OK); ::MessageBoxA(NULL, e.what(), "PluginsManager::runPluginCommand Exception", MB_OK);
} }
@ -546,7 +546,7 @@ void PluginsManager::runPluginCommand(const TCHAR *pluginName, int commandID)
{ {
_pluginsCommands[i]._pFunc(); _pluginsCommands[i]._pFunc();
} }
catch (std::exception e) catch (std::exception& e)
{ {
::MessageBoxA(NULL, e.what(), "Exception", MB_OK); ::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} }
@ -575,7 +575,7 @@ void PluginsManager::notify(const SCNotification *notification)
{ {
_pluginInfos[i]->_pBeNotified(&scNotif); _pluginInfos[i]->_pBeNotified(&scNotif);
} }
catch (std::exception e) catch (std::exception& e)
{ {
::MessageBoxA(NULL, e.what(), "Exception", MB_OK); ::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} }
@ -601,7 +601,7 @@ void PluginsManager::relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam
{ {
_pluginInfos[i]->_pMessageProc(Message, wParam, lParam); _pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
} }
catch (std::exception e) catch (std::exception& e)
{ {
::MessageBoxA(NULL, e.what(), "Exception", MB_OK); ::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} }
@ -632,7 +632,7 @@ bool PluginsManager::relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lPa
{ {
_pluginInfos[i]->_pMessageProc(Message, wParam, lParam); _pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
} }
catch (std::exception e) catch (std::exception& e)
{ {
::MessageBoxA(NULL, e.what(), "Exception", MB_OK); ::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} }

View File

@ -107,7 +107,7 @@ LRESULT Notepad_plus_Window::runProc(HWND hwnd, UINT message, WPARAM wParam, LPA
_notepad_plus_plus_core._pPublicInterface = this; _notepad_plus_plus_core._pPublicInterface = this;
return _notepad_plus_plus_core.init(hwnd); return _notepad_plus_plus_core.init(hwnd);
} }
catch (std::exception ex) catch (std::exception& ex)
{ {
::MessageBoxA(hwnd, ex.what(), "Exception On WM_CREATE", MB_OK); ::MessageBoxA(hwnd, ex.what(), "Exception On WM_CREATE", MB_OK);
exit(-1); exit(-1);

View File

@ -180,7 +180,7 @@ TCHAR* FileDialog::doOpenSingleFileDlg()
::GetCurrentDirectory(MAX_PATH, dir); ::GetCurrentDirectory(MAX_PATH, dir);
params->setWorkingDir(dir); params->setWorkingDir(dir);
} }
} catch(std::exception e) { } catch(std::exception& e) {
::MessageBoxA(NULL, e.what(), "Exception", MB_OK); ::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} catch(...) { } catch(...) {
::MessageBox(NULL, TEXT("doOpenSingleFileDlg crashes!!!"), TEXT(""), MB_OK); ::MessageBox(NULL, TEXT("doOpenSingleFileDlg crashes!!!"), TEXT(""), MB_OK);
@ -268,7 +268,7 @@ TCHAR * FileDialog::doSaveDlg()
::GetCurrentDirectory(MAX_PATH, dir); ::GetCurrentDirectory(MAX_PATH, dir);
params->setWorkingDir(dir); params->setWorkingDir(dir);
} }
} catch(std::exception e) { } catch(std::exception& e) {
::MessageBoxA(NULL, e.what(), "Exception", MB_OK); ::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} catch(...) { } catch(...) {
::MessageBox(NULL, TEXT("GetSaveFileName crashes!!!"), TEXT(""), MB_OK); ::MessageBox(NULL, TEXT("GetSaveFileName crashes!!!"), TEXT(""), MB_OK);