mirror of
https://github.com/edubart/otclient.git
synced 2025-10-16 04:24:54 +02:00
Make C++ exception works for lua
* Throw exception when open a file fails
This commit is contained in:
@@ -122,11 +122,11 @@ bool InputMessage::canRead(int bytes)
|
||||
void InputMessage::checkRead(int bytes)
|
||||
{
|
||||
if(!canRead(bytes))
|
||||
g_lua.throwError("InputMessage eof reached");
|
||||
throw stdext::exception("InputMessage eof reached");
|
||||
}
|
||||
|
||||
void InputMessage::checkWrite(int bytes)
|
||||
{
|
||||
if(bytes > BUFFER_MAXSIZE)
|
||||
g_lua.throwError("InputMessage max buffer size reached");
|
||||
throw stdext::exception("InputMessage max buffer size reached");
|
||||
}
|
||||
|
@@ -71,7 +71,7 @@ void OutputMessage::addString(const std::string& buffer)
|
||||
{
|
||||
int len = buffer.length();
|
||||
if(len > MAX_STRING_LENGTH)
|
||||
g_lua.throwError(stdext::format("string length > %d", MAX_STRING_LENGTH));
|
||||
throw stdext::exception(stdext::format("string length > %d", MAX_STRING_LENGTH));
|
||||
checkWrite(len + 2);
|
||||
addU16(len);
|
||||
memcpy((char*)(m_buffer + m_writePos), buffer.c_str(), len);
|
||||
@@ -92,7 +92,7 @@ void OutputMessage::addPaddingBytes(int bytes, uint8 byte)
|
||||
void OutputMessage::encryptRSA(int size, const std::string& key)
|
||||
{
|
||||
if(m_messageSize < size)
|
||||
g_lua.throwError("insufficient bytes in buffer to encrypt");
|
||||
throw stdext::exception("insufficient bytes in buffer to encrypt");
|
||||
|
||||
RSA::encrypt((char*)m_buffer + m_writePos - size, size, key.c_str());
|
||||
}
|
||||
@@ -124,5 +124,5 @@ bool OutputMessage::canWrite(int bytes)
|
||||
void OutputMessage::checkWrite(int bytes)
|
||||
{
|
||||
if(!canWrite(bytes))
|
||||
g_lua.throwError("OutputMessage max buffer size reached");
|
||||
throw stdext::exception("OutputMessage max buffer size reached");
|
||||
}
|
||||
|
Reference in New Issue
Block a user