mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
Merge pull request #85 from Holt59/moexception
Rename MyException to MOException
This commit is contained in:
@@ -50,17 +50,17 @@ QString ExtractResource(WORD resourceID, const QString &szFilename)
|
||||
|
||||
HRSRC hResource = FindResourceW(mod, MAKEINTRESOURCE(resourceID), L"BINARY");
|
||||
if (hResource == nullptr) {
|
||||
throw MyException("embedded dll not available: " + windowsErrorString(::GetLastError()));
|
||||
throw Exception("embedded dll not available: " + windowsErrorString(::GetLastError()));
|
||||
}
|
||||
|
||||
HGLOBAL hFileResource = LoadResource(mod, hResource);
|
||||
if (hFileResource == nullptr) {
|
||||
throw MyException("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 MyException(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 MyException(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 MyException(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 MyException(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 MyException("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 MyException(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 MyException(QString("invalid problem key %1").arg(key));
|
||||
throw Exception(QString("invalid problem key %1").arg(key));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -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::MyException {
|
||||
class MissingImplementation : public MOBase::Exception {
|
||||
public:
|
||||
MissingImplementation(std::string const& className, std::string const& methodName) :
|
||||
MyException(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::MyException {
|
||||
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() : MyException(getPythonErrorMessage()) { }
|
||||
PythonError() : Exception(getPythonErrorMessage()) { }
|
||||
|
||||
/**
|
||||
* @brief Create a new PythonError with the given message.
|
||||
*
|
||||
* @param message Message for the exception.
|
||||
*/
|
||||
PythonError(QString message) : MyException(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::MyException {
|
||||
class UnknownException : public MOBase::Exception {
|
||||
public:
|
||||
|
||||
/**
|
||||
@@ -99,14 +99,14 @@ namespace pyexcept {
|
||||
*
|
||||
* @see defaultErrorMessage
|
||||
*/
|
||||
UnknownException() : MyException(defaultErrorMessage()) { }
|
||||
UnknownException() : Exception(defaultErrorMessage()) { }
|
||||
|
||||
/**
|
||||
* @brief Create a new UnknownException with the given message.
|
||||
*
|
||||
* @param message Message for the exception.
|
||||
*/
|
||||
UnknownException(QString message) : MyException(message) { }
|
||||
UnknownException(QString message) : Exception(message) { }
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ const sipAPIDef* sipAPIAccess::sipAPI()
|
||||
exception = QString::fromStdString(returned());
|
||||
}
|
||||
PyErr_Restore(type, value, traceback);
|
||||
throw MOBase::MyException(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::MyException(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;
|
||||
|
||||
Reference in New Issue
Block a user