From cd9b16dcc2796e9e7588db2fcd7fc25111183b16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Fri, 4 Dec 2020 12:04:45 +0100 Subject: [PATCH] MOException -> Exception. --- src/proxy/proxypython.cpp | 18 +++++++++--------- src/runner/error.h | 16 ++++++++-------- src/runner/sipapiaccess.cpp | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/proxy/proxypython.cpp b/src/proxy/proxypython.cpp index 24906b2..6d75ee7 100644 --- a/src/proxy/proxypython.cpp +++ b/src/proxy/proxypython.cpp @@ -50,17 +50,17 @@ QString ExtractResource(WORD resourceID, const QString &szFilename) HRSRC hResource = FindResourceW(mod, MAKEINTRESOURCE(resourceID), L"BINARY"); if (hResource == nullptr) { - throw MOException("embedded dll not available: " + windowsErrorString(::GetLastError())); + throw Exception("embedded dll not available: " + windowsErrorString(::GetLastError())); } HGLOBAL hFileResource = LoadResource(mod, hResource); if (hFileResource == nullptr) { - throw MOException("failed to load embedded dll resource: " + windowsErrorString(::GetLastError())); + throw Exception("failed to load embedded dll resource: " + windowsErrorString(::GetLastError())); } LPVOID lpFile = LockResource(hFileResource); if (lpFile == nullptr) { - throw MOException(QString("failed to lock resource: %1").arg(windowsErrorString(::GetLastError()))); + throw Exception(QString("failed to lock resource: %1").arg(windowsErrorString(::GetLastError()))); } DWORD dwSize = SizeofResource(mod, hResource); @@ -73,16 +73,16 @@ QString ExtractResource(WORD resourceID, const QString &szFilename) // dll exists and is opened by another instance of MO, shouldn't be outdated then... return outFile; } else { - throw MOException(QString("failed to open python runner: %1").arg(windowsErrorString(::GetLastError()))); + throw Exception(QString("failed to open python runner: %1").arg(windowsErrorString(::GetLastError()))); } } HANDLE hFileMap = CreateFileMapping(hFile, nullptr, PAGE_READWRITE, 0, dwSize, nullptr); if (hFileMap == NULL) { - throw MOException(QString("failed to map python runner: %1").arg(windowsErrorString(::GetLastError()))); + throw Exception(QString("failed to map python runner: %1").arg(windowsErrorString(::GetLastError()))); } LPVOID lpAddress = MapViewOfFile(hFileMap, FILE_MAP_WRITE, 0, 0, 0); if (lpAddress == nullptr) { - throw MOException(QString("failed to map view of file: %1").arg(windowsErrorString(::GetLastError()))); + throw Exception(QString("failed to map view of file: %1").arg(windowsErrorString(::GetLastError()))); } CopyMemory(lpAddress, lpFile, dwSize); @@ -147,7 +147,7 @@ bool ProxyPython::init(IOrganizer *moInfo) if (m_RunnerLib != nullptr) { CreatePythonRunner_func CreatePythonRunner = (CreatePythonRunner_func)::GetProcAddress(m_RunnerLib, "CreatePythonRunner"); if (CreatePythonRunner == nullptr) { - throw MOException("embedded dll is invalid: " + windowsErrorString(::GetLastError())); + throw Exception("embedded dll is invalid: " + windowsErrorString(::GetLastError())); } if (m_MOInfo && m_MOInfo->persistent(name(), "tryInit", false).toBool()) { @@ -315,7 +315,7 @@ QString ProxyPython::shortDescription(unsigned int key) const return tr("ModOrganizer path contains a semicolon"); } break; default: - throw MOException(tr("invalid problem key %1").arg(key)); + throw Exception(tr("invalid problem key %1").arg(key)); } } @@ -354,7 +354,7 @@ QString ProxyPython::fullDescription(unsigned int key) const "The only solution I can offer is to remove the semicolon / move MO to a path without a semicolon.").arg(QCoreApplication::applicationDirPath()); } break; default: - throw MOException(QString("invalid problem key %1").arg(key)); + throw Exception(QString("invalid problem key %1").arg(key)); } } diff --git a/src/runner/error.h b/src/runner/error.h index 82021ff..b44bd5b 100644 --- a/src/runner/error.h +++ b/src/runner/error.h @@ -31,10 +31,10 @@ namespace pyexcept { * @brief Exception to throw when a python implementation does not implement * a pure virtual function. */ - class MissingImplementation : public MOBase::MOException { + class MissingImplementation : public MOBase::Exception { public: MissingImplementation(std::string const& className, std::string const& methodName) : - MOException(QString::fromStdString( + Exception(QString::fromStdString( fmt::format("Python class implementing \"{}\" has no implementation of method \"{}\".", className, methodName))) { } @@ -43,21 +43,21 @@ namespace pyexcept { /** * @brief Exception to throw when a python error occurs. */ - class PythonError : public MOBase::MOException { + class PythonError : public MOBase::Exception { public: /** * @brief Create a new PythonError, fetching the error message from python. If the message * cannot be retrieved, `defaultErrorMessage()` is used instead. */ - PythonError() : MOException(getPythonErrorMessage()) { } + PythonError() : Exception(getPythonErrorMessage()) { } /** * @brief Create a new PythonError with the given message. * * @param message Message for the exception. */ - PythonError(QString message) : MOException(message) { } + PythonError(QString message) : Exception(message) { } protected: @@ -91,7 +91,7 @@ namespace pyexcept { * @brief Exception to throw when an unknown error occured. This is typically thrown * from a catch(...) block. */ - class UnknownException : public MOBase::MOException { + class UnknownException : public MOBase::Exception { public: /** @@ -99,14 +99,14 @@ namespace pyexcept { * * @see defaultErrorMessage */ - UnknownException() : MOException(defaultErrorMessage()) { } + UnknownException() : Exception(defaultErrorMessage()) { } /** * @brief Create a new UnknownException with the given message. * * @param message Message for the exception. */ - UnknownException(QString message) : MOException(message) { } + UnknownException(QString message) : Exception(message) { } protected: diff --git a/src/runner/sipapiaccess.cpp b/src/runner/sipapiaccess.cpp index 87b0984..b93d6f3 100644 --- a/src/runner/sipapiaccess.cpp +++ b/src/runner/sipapiaccess.cpp @@ -28,7 +28,7 @@ const sipAPIDef* sipAPIAccess::sipAPI() exception = QString::fromStdString(returned()); } PyErr_Restore(type, value, traceback); - throw MOBase::MOException(QString("Failed to load PyQt5: %1").arg(exception)); + throw MOBase::Exception(QString("Failed to load PyQt5: %1").arg(exception)); } sipApi = (const sipAPIDef*)PyCapsule_Import("PyQt5.sip._C_API", 0); @@ -51,7 +51,7 @@ const sipAPIDef* sipAPIAccess::sipAPI() } PyErr_Restore(type, value, traceback); } - throw MOBase::MOException(QString("Failed to load SIP API: %1").arg(exception)); + throw MOBase::Exception(QString("Failed to load SIP API: %1").arg(exception)); } #else PyObject* sip_module;