Skip to content

Commit

Permalink
Merge branch 'npp_official_svn' into jl/LH-45/integrate-npp-svn
Browse files Browse the repository at this point in the history
[CLEAN] throw runtime_error instead of int.

Conflicts:
	PowerEditor/src/Parameters.cpp
	PowerEditor/src/ScintillaComponent/FindReplaceDlg.h
	PowerEditor/src/ScintillaComponent/GoToLineDlg.h
	PowerEditor/src/ScintillaComponent/columnEditor.h
	PowerEditor/src/WinControls/SplitterContainer/Splitter.cpp

[#45]

Signed-off-by: Jocelyn Legault <jocelynlegault@gmail.com>
  • Loading branch information
joce committed Oct 6, 2010
2 parents 803bde1 + 21d033d commit f3b47eb
Show file tree
Hide file tree
Showing 24 changed files with 103 additions and 126 deletions.
21 changes: 15 additions & 6 deletions PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,10 @@ int PluginsManager::loadPlugin(const generic_string& pluginFilePath, std::vector

_pluginInfos.push_back(pi);
return (_pluginInfos.size() - 1);
}
catch(generic_string s)
{
} catch(std::exception e) {
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
return -1;
} catch(generic_string s) {
s += TEXT("\n\n");
s += USERMSG;
if (::MessageBox(NULL, s.c_str(), pluginFilePath.c_str(), MB_YESNO) == IDYES)
Expand All @@ -232,9 +233,7 @@ int PluginsManager::loadPlugin(const generic_string& pluginFilePath, std::vector
}
delete pi;
return -1;
}
catch(...)
{
} catch(...) {
generic_string msg = TEXT("Fail loaded");
msg += TEXT("\n\n");
msg += USERMSG;
Expand Down Expand Up @@ -408,6 +407,8 @@ void PluginsManager::runPluginCommand(size_t i)
{
try {
_pluginsCommands[i]._pFunc();
} catch(std::exception e) {
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} catch (...) {
TCHAR funcInfo[128];
generic_sprintf(funcInfo, 128, TEXT("runPluginCommand(size_t i : %d)"), i);
Expand All @@ -428,6 +429,8 @@ void PluginsManager::runPluginCommand(const TCHAR *pluginName, int commandID)
{
try {
_pluginsCommands[i]._pFunc();
} catch(std::exception e) {
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} catch (...) {
TCHAR funcInfo[128];
generic_sprintf(funcInfo, 128, TEXT("runPluginCommand(const TCHAR *pluginName : %s, int commandID : %d)"), pluginName, commandID);
Expand All @@ -449,6 +452,8 @@ void PluginsManager::notify(SCNotification *notification)
SCNotification scNotif = *notification;
try {
_pluginInfos[i]->_pBeNotified(&scNotif);
} catch(std::exception e) {
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} catch (...) {
TCHAR funcInfo[128];
generic_sprintf(funcInfo, 128, TEXT("notify(SCNotification *notification) : \r notification->nmhdr.code == %d\r notification->nmhdr.hwndFrom == %d\r notification->nmhdr.idFrom == %d"),\
Expand All @@ -467,6 +472,8 @@ void PluginsManager::relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam
{
try {
_pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
} catch(std::exception e) {
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} catch (...) {
TCHAR funcInfo[128];
generic_sprintf(funcInfo, 128, TEXT("relayNppMessages(UINT Message : %d, WPARAM wParam : %d, LPARAM lParam : %d)"), Message, wParam, lParam);
Expand All @@ -490,6 +497,8 @@ bool PluginsManager::relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lPa
{
try {
_pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
} catch(std::exception e) {
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} catch (...) {
TCHAR funcInfo[128];
generic_sprintf(funcInfo, 128, TEXT("relayPluginMessages(UINT Message : %d, WPARAM wParam : %d, LPARAM lParam : %d)"), Message, wParam, lParam);
Expand Down
8 changes: 3 additions & 5 deletions PowerEditor/src/Notepad_plus_Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin

if (!::RegisterClass(&nppClass))
{
systemMessage(TEXT("System Err"));
throw int(98);
throw std::runtime_error("Notepad_plus_Window::init : RegisterClass() function failed");
}

RECT workAreaRect;
Expand Down Expand Up @@ -100,8 +99,7 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin

if (!_hSelf)
{
systemMessage(TEXT("System Err"));
throw int(777);
throw std::runtime_error("Notepad_plus_Window::init : CreateWindowEx() function return null");
}

gNppHWND = _hSelf;
Expand Down Expand Up @@ -249,4 +247,4 @@ HACCEL Notepad_plus_Window::getAccTable() const
bool Notepad_plus_Window::emergency( generic_string emergencySavedDir )
{
return _notepad_plus_plus_core->emergency(emergencySavedDir);
}
}
25 changes: 13 additions & 12 deletions PowerEditor/src/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1922,8 +1922,6 @@ bool NppParameters::getShortcuts(TiXmlNode *node, Shortcut & sc)
}


const int loadFailed = 100;
const int missingName = 101;
bool NppParameters::feedUserLang(TiXmlNode *node)
{
bool isEverythingOK = true;
Expand All @@ -1938,26 +1936,29 @@ bool NppParameters::feedUserLang(TiXmlNode *node)
hasFoundElement = true;
UserLangContainer* newLangContainer = new UserLangContainer(name, ext);
try {
if (!name || !name[0] || !ext) throw int(missingName);
if (!name || !name[0] || !ext)
throw std::runtime_error("NppParameters::feedUserLang : UserLang name is missing");

TiXmlNode *settingsRoot = childNode->FirstChildElement(TEXT("Settings"));
if (!settingsRoot) throw int(loadFailed);
if (!settingsRoot)
throw std::runtime_error("NppParameters::feedUserLang : Settings node is missing");
newLangContainer->feedUserSettings(settingsRoot);

TiXmlNode *keywordListsRoot = childNode->FirstChildElement(TEXT("KeywordLists"));
if (!keywordListsRoot) throw int(loadFailed);
if (!keywordListsRoot)
throw std::runtime_error("NppParameters::feedUserLang : KeywordLists node is missing");

newLangContainer->feedUserKeywordList(keywordListsRoot);

TiXmlNode *stylesRoot = childNode->FirstChildElement(TEXT("Styles"));
if (!stylesRoot) throw int(loadFailed);
if (!stylesRoot)
throw std::runtime_error("NppParameters::feedUserLang : Styles node is missing");

newLangContainer->feedUserStyles(stylesRoot);

} catch (int e) {
if (e == loadFailed)
{
delete newLangContainer;
newLangContainer = NULL;
}
} catch (std::exception e) {
delete newLangContainer;
newLangContainer = NULL;
isEverythingOK = false;
}

Expand Down
5 changes: 3 additions & 2 deletions PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,7 @@ void FindReplaceDlg::init( HINSTANCE hInst, HWND hParent, ScintillaEditView **pp
Window::init(hInst, hParent);
if (!ppEditView)
{
throw int(9900);
throw std::runtime_error("FindIncrementDlg::init : ppEditView is null.");
}
_ppEditView = ppEditView;
}
Expand Down Expand Up @@ -2343,7 +2343,8 @@ void FindIncrementDlg::init(HINSTANCE hInst, HWND hParent, FindReplaceDlg *pFRDl
{
Window::init(hInst, hParent);
if (!pFRDlg)
throw int(9910);
throw std::runtime_error("FindIncrementDlg::init : Parameter pFRDlg is null");

_pFRDlg = pFRDlg;
create(IDD_INCREMENT_FIND, isRTL);
_isRTL = isRTL;
Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/ScintillaComponent/GoToLineDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void GoToLineDlg::init( HINSTANCE hInst, HWND hParent, ScintillaEditView **ppEdi
{
Window::init(hInst, hParent);
if (!ppEditView)
throw int(9900);
throw std::runtime_error("GoToLineDlg::init : ppEditView is null.");
_ppEditView = ppEditView;
}

Expand Down
16 changes: 9 additions & 7 deletions PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hParent)
{
if (!_hLib)
{
MessageBox( NULL, TEXT("Can not load the dynamic library"), TEXT("SCINTILLA ERROR : "), MB_OK | MB_ICONSTOP);
throw int(106901);
throw std::runtime_error("ScintillaEditView::init : SCINTILLA ERROR - Can not load the dynamic library");
}

Window::init(hInst, hParent);
Expand All @@ -170,19 +169,22 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hParent)

if (!_hSelf)
{
systemMessage(TEXT("System Error"));
throw int(106901);
throw std::runtime_error("ScintillaEditView::init : CreateWindowEx() function return null");
}

_pScintillaFunc = (SCINTILLA_FUNC)::SendMessage(_hSelf, SCI_GETDIRECTFUNCTION, 0, 0);
_pScintillaPtr = (SCINTILLA_PTR)::SendMessage(_hSelf, SCI_GETDIRECTPOINTER, 0, 0);

s_userDefineDlg.init(_hInst, _hParent, this);

if (!_pScintillaFunc || !_pScintillaPtr)
if (!_pScintillaFunc)
{
systemMessage(TEXT("System Err"));
throw int(106901);
throw std::runtime_error("ScintillaEditView::init : SCI_GETDIRECTFUNCTION message failed");
}

if (!_pScintillaPtr)
{
throw std::runtime_error("ScintillaEditView::init : SCI_GETDIRECTPOINTER message failed");
}

execute(SCI_SETMARGINMASKN, _SC_MARGIN_FOLDER, SC_MASK_FOLDERS);
Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/ScintillaComponent/columnEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void ColumnEditorDlg::init(HINSTANCE hInst, HWND hParent, ScintillaEditView **pp
{
Window::init(hInst, hParent);
if (!ppEditView)
throw int(9900);
throw std::runtime_error("StaticDialog::init : ppEditView is null.");
_ppEditView = ppEditView;
}

Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void ColourPicker::init(HINSTANCE hInst, HWND parent)
if (!_hSelf)
{
systemMessage(TEXT("System Err"));
throw int(6969);
throw std::runtime_error("ColourPicker::init : CreateWindowEx() function return null");
}


Expand Down
3 changes: 1 addition & 2 deletions PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ void ColourPopup::create(int dialogID)

if (!_hSelf)
{
systemMessage(TEXT("ColourPopup"));
throw int(696);
throw std::runtime_error("ColourPopup::create : CreateDialogParam() function return null");
}
Window::getClientRect(_rc);
display();
Expand Down
9 changes: 3 additions & 6 deletions PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ void DockingManager::init(HINSTANCE hInst, HWND hWnd, Window ** ppWin)

if (!::RegisterClass(&clz))
{
systemMessage(TEXT("System Err"));
throw int(98);
throw std::runtime_error("DockingManager::init : RegisterClass() function failed");
}
_isRegistered = TRUE;
}
Expand All @@ -143,8 +142,7 @@ void DockingManager::init(HINSTANCE hInst, HWND hWnd, Window ** ppWin)

if (!_hSelf)
{
systemMessage(TEXT("System Err"));
throw int(777);
throw std::runtime_error("DockingManager::init : CreateWindowEx() function return null");
}

setClientWnd(ppWin);
Expand All @@ -170,8 +168,7 @@ void DockingManager::init(HINSTANCE hInst, HWND hWnd, Window ** ppWin)

if (!gWinCallHook)
{
systemMessage(TEXT("System Err"));
throw int(1000);
throw std::runtime_error("DockingManager::init : SetWindowsHookEx() function return null");
}

_dockData->hWnd = _hSelf;
Expand Down
6 changes: 2 additions & 4 deletions PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ void DockingSplitter::init(HINSTANCE hInst, HWND hWnd, HWND hMessage, UINT flags

if (!::RegisterClass(&wc))
{
systemMessage(TEXT("System Err"));
throw int(98);
throw std::runtime_error("DockingSplitter::init : RegisterClass() function failed");
}
else if (flags & DMS_HORIZONTAL)
{
Expand All @@ -108,8 +107,7 @@ void DockingSplitter::init(HINSTANCE hInst, HWND hWnd, HWND hMessage, UINT flags

if (!_hSelf)
{
systemMessage(TEXT("System Err"));
throw int(777);
throw std::runtime_error("DockingSplitter::init : CreateWindowEx() function return null");
}
}

Expand Down
6 changes: 2 additions & 4 deletions PowerEditor/src/WinControls/DockingWnd/Gripper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ void Gripper::startGrip(DockingCont* pCont, DockingManager* pDockMgr)

if (!::RegisterClass(&clz))
{
systemMessage(TEXT("System Err"));
throw int(98);
throw std::runtime_error("Gripper::startGrip : RegisterClass() function failed");
}
_isRegistered = TRUE;
}
Expand All @@ -151,8 +150,7 @@ void Gripper::startGrip(DockingCont* pCont, DockingManager* pDockMgr)

if (!_hSelf)
{
systemMessage(TEXT("System Err"));
throw int(777);
throw std::runtime_error("Gripper::startGrip : CreateWindowEx() function return null");
}
}

Expand Down
5 changes: 3 additions & 2 deletions PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void IconList::create(HINSTANCE hInst, int iconSize)
_iconSize = iconSize;
_hImglst = ImageList_Create(iconSize, iconSize, ILC_COLOR32 | ILC_MASK, 0, NB_MAX_COMMANDS);
if (!_hImglst)
throw int(25);
throw std::runtime_error("IconList::create : ImageList_Create() function return null");
};

void IconList::create(int iconSize, HINSTANCE hInst, int *iconIDArray, int iconIDArraySize)
Expand All @@ -42,7 +42,8 @@ void IconList::addIcon(int iconID) const
{
HICON hIcon = ::LoadIcon(_hInst, MAKEINTRESOURCE(iconID));
if (!hIcon)
throw int(26);
throw std::runtime_error("IconList::addIcon : LoadIcon() function return null");

ImageList_AddIcon(_hImglst, hIcon);
::DestroyIcon(hIcon);
};
Expand Down
10 changes: 6 additions & 4 deletions PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ TCHAR * FileDialog::doOpenSingleFileDlg()
::GetCurrentDirectory(MAX_PATH, dir);
params->setWorkingDir(dir);
}
}
catch(...) {
} catch(std::exception e) {
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} catch(...) {
::MessageBox(NULL, TEXT("GetSaveFileName crashes!!!"), TEXT(""), MB_OK);
}

Expand Down Expand Up @@ -298,8 +299,9 @@ TCHAR * FileDialog::doSaveDlg()
::GetCurrentDirectory(MAX_PATH, dir);
params->setWorkingDir(dir);
}
}
catch(...) {
} catch(std::exception e) {
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} catch(...) {
::MessageBox(NULL, TEXT("GetSaveFileName crashes!!!"), TEXT(""), MB_OK);
}

Expand Down

0 comments on commit f3b47eb

Please sign in to comment.