From 7bb0d5f947b9add5b2de510701b18741500724f4 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Sat, 9 Jul 2016 14:18:09 +0300 Subject: [PATCH] Adjust the code to use the .what() method from the Sqrat exception. --- modules/irc/Session.cpp | 10 +++++----- modules/sqlite/Connection.cpp | 8 ++++---- modules/sqlite/Handle/Connection.cpp | 2 +- source/Command.cpp | 6 +++--- source/Command.hpp | 2 +- source/Core.cpp | 2 +- source/Entity/Player.cpp | 16 ++++++++-------- source/Library/Numeric/Math.cpp | 4 ++-- source/Library/String.cpp | 12 ++++++------ source/Main.cpp | 2 +- source/Misc/Broadcast.cpp | 8 ++++---- source/Routine.cpp | 2 +- 12 files changed, 37 insertions(+), 37 deletions(-) diff --git a/modules/irc/Session.cpp b/modules/irc/Session.cpp index c101d4be..c494db42 100644 --- a/modules/irc/Session.cpp +++ b/modules/irc/Session.cpp @@ -699,7 +699,7 @@ void Session::ForwardEvent(Function & listener, CCStr event, CCStr origin, CCStr } catch (const Sqrat::Exception & e) { - SqMod_LogErr("IRC event [%s] => Squirrel error [%s]", event, e.Message().c_str()); + SqMod_LogErr("IRC event [%s] => Squirrel error [%s]", event, e.what()); } catch (const std::exception & e) { @@ -743,7 +743,7 @@ void Session::ForwardEvent(Function & listener, Uint32 event, } catch (const Sqrat::Exception & e) { - SqMod_LogErr("IRC event [%s] => Squirrel error [%s]", event, e.Message().c_str()); + SqMod_LogErr("IRC event [%s] => Squirrel error [%s]", event, e.what()); } catch (const std::exception & e) { @@ -1014,7 +1014,7 @@ SQInteger Session::CmdMsgF(HSQUIRRELVM vm) catch (const Sqrat::Exception & e) { // Propagate the error - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } // Do we have a valid session instance? if (!session) @@ -1078,7 +1078,7 @@ SQInteger Session::CmdMeF(HSQUIRRELVM vm) catch (const Sqrat::Exception & e) { // Propagate the error - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } // Do we have a valid session instance? if (!session) @@ -1142,7 +1142,7 @@ SQInteger Session::CmdNoticeF(HSQUIRRELVM vm) catch (const Sqrat::Exception & e) { // Propagate the error - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } // Do we have a valid session instance? if (!session) diff --git a/modules/sqlite/Connection.cpp b/modules/sqlite/Connection.cpp index 37735aac..4810e227 100644 --- a/modules/sqlite/Connection.cpp +++ b/modules/sqlite/Connection.cpp @@ -363,7 +363,7 @@ SQInteger Connection::ExecF(HSQUIRRELVM vm) catch (const Sqrat::Exception & e) { // Propagate the error - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } // Do we have a valid connection instance? if (!conn) @@ -414,7 +414,7 @@ SQInteger Connection::QueueF(HSQUIRRELVM vm) catch (const Sqrat::Exception & e) { // Propagate the error - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } // Do we have a valid connection instance? if (!conn) @@ -458,7 +458,7 @@ SQInteger Connection::QueryF(HSQUIRRELVM vm) catch (const Sqrat::Exception & e) { // Propagate the error - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } // Do we have a valid connection instance? if (!conn) @@ -484,7 +484,7 @@ SQInteger Connection::QueryF(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } // This function returned a value return 1; diff --git a/modules/sqlite/Handle/Connection.cpp b/modules/sqlite/Handle/Connection.cpp index 7349172b..c801b71a 100644 --- a/modules/sqlite/Handle/Connection.cpp +++ b/modules/sqlite/Handle/Connection.cpp @@ -127,7 +127,7 @@ Int32 ConnHnd::Flush(Uint32 num, Object & env, Function & func) } catch (const Sqrat::Exception & e) { - SqMod_LogErr("Squirrel error caught in flush handler [%s]", e.Message().c_str()); + SqMod_LogErr("Squirrel error caught in flush handler [%s]", e.what()); } catch (const std::exception & e) { diff --git a/source/Command.cpp b/source/Command.cpp index a4d79a00..120d5274 100644 --- a/source/Command.cpp +++ b/source/Command.cpp @@ -208,7 +208,7 @@ Int32 Controller::Run(const Guard & guard, CCStr command) catch (const Sqrat::Exception & e) { // Tell the script callback to deal with the error - SqError(CMDERR_INVALID_COMMAND, e.Message().c_str(), guard.mCurrent->mInvoker); + SqError(CMDERR_INVALID_COMMAND, e.what(), guard.mCurrent->mInvoker); // Execution failed! return -1; } @@ -350,7 +350,7 @@ Int32 Controller::Exec(Context & ctx) catch (const Sqrat::Exception & e) { // Let's store the exception message - ctx.mBuffer.Write(0, e.Message().c_str(), e.Message().size()); + ctx.mBuffer.Write(0, e.what(), e.Message().size()); // Specify that the command execution failed failed = true; } @@ -379,7 +379,7 @@ Int32 Controller::Exec(Context & ctx) catch (const Sqrat::Exception & e) { // Let's store the exception message - ctx.mBuffer.Write(0, e.Message().c_str(), e.Message().size()); + ctx.mBuffer.Write(0, e.what(), e.Message().size()); // Specify that the command execution failed failed = true; } diff --git a/source/Command.hpp b/source/Command.hpp index 8d65928c..d33b6c4c 100644 --- a/source/Command.hpp +++ b/source/Command.hpp @@ -394,7 +394,7 @@ protected: catch (const Sqrat::Exception & e) { // We can only log this incident and in the future maybe also include the location - LogErr("Command error callback failed [%s]", e.Message().c_str()); + LogErr("Command error callback failed [%s]", e.what()); } } diff --git a/source/Core.cpp b/source/Core.cpp index ed6a392a..b4c36c1a 100644 --- a/source/Core.cpp +++ b/source/Core.cpp @@ -518,7 +518,7 @@ bool Core::LoadScript(CSStr filepath, bool delay) } catch (const Sqrat::Exception & e) { - LogErr("Unable to load script: %s", e.Message().c_str()); + LogErr("Unable to load script: %s", e.what()); // Failed to load return false; } diff --git a/source/Entity/Player.cpp b/source/Entity/Player.cpp index cacd3fbe..182656e1 100644 --- a/source/Entity/Player.cpp +++ b/source/Entity/Player.cpp @@ -1673,7 +1673,7 @@ SQInteger CPlayer::Msg(HSQUIRRELVM vm) catch (const Sqrat::Exception & e) { // Propagate the error - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } // Do we have a valid player instance? @@ -1747,7 +1747,7 @@ SQInteger CPlayer::MsgP(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } // Do we have a valid player instance? @@ -1770,7 +1770,7 @@ SQInteger CPlayer::MsgP(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } // Perform a range check on the specified prefix index @@ -1841,7 +1841,7 @@ SQInteger CPlayer::MsgEx(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } // Do we have a valid player instance? @@ -1864,7 +1864,7 @@ SQInteger CPlayer::MsgEx(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } // Perform a range check on the specified prefix index @@ -1937,7 +1937,7 @@ SQInteger CPlayer::Message(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } // Do we have a valid player instance? @@ -1994,7 +1994,7 @@ SQInteger CPlayer::Announce(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } // Do we have a valid player instance? @@ -2064,7 +2064,7 @@ SQInteger CPlayer::AnnounceEx(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what())); } // Do we have a valid player instance? diff --git a/source/Library/Numeric/Math.cpp b/source/Library/Numeric/Math.cpp index 59d48e56..3342a8aa 100644 --- a/source/Library/Numeric/Math.cpp +++ b/source/Library/Numeric/Math.cpp @@ -191,7 +191,7 @@ static SQInteger SqNanL(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } catch (const std::exception e) { @@ -696,7 +696,7 @@ static SQInteger SqRoundL(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } catch (const std::exception e) { diff --git a/source/Library/String.cpp b/source/Library/String.cpp index 0882ebaf..bfead7ed 100644 --- a/source/Library/String.cpp +++ b/source/Library/String.cpp @@ -83,7 +83,7 @@ static SQInteger SqLeftStr(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } catch (...) { @@ -182,7 +182,7 @@ static SQInteger SqLeftOffsetStr(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } catch (...) { @@ -274,7 +274,7 @@ static SQInteger SqRightStr(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } catch (...) { @@ -373,7 +373,7 @@ static SQInteger SqRightOffsetStr(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } catch (...) { @@ -460,7 +460,7 @@ static SQInteger SqCenterStr(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } catch (...) { @@ -1096,7 +1096,7 @@ static SQInteger SqStrExplode(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } catch (...) { diff --git a/source/Main.cpp b/source/Main.cpp index a4de523d..9ea291e6 100644 --- a/source/Main.cpp +++ b/source/Main.cpp @@ -76,7 +76,7 @@ void UnbindCallbacks(); */ catch (const Sqrat::Exception & e) /* */ { /* */ LogErr("Squirrel exception caught (" #ev ") event"); /* -*/ LogInf("Message: %s", e.Message().c_str()); /* +*/ LogInf("Message: %s", e.what()); /* */ } /* */ catch (const std::exception & e) /* */ { /* diff --git a/source/Misc/Broadcast.cpp b/source/Misc/Broadcast.cpp index 84eb6e49..93086056 100644 --- a/source/Misc/Broadcast.cpp +++ b/source/Misc/Broadcast.cpp @@ -51,7 +51,7 @@ SQRESULT SqGrabPlayerMessageColor(HSQUIRRELVM vm, Int32 idx, Uint32 & color, Int } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } } // The message starts right after the color @@ -328,7 +328,7 @@ static SQInteger SqBroadcastMsgP(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } // Perform a range check on the specified prefix index @@ -421,7 +421,7 @@ static SQInteger SqBroadcastMsgEx(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } // Perform a range check on the specified prefix index @@ -637,7 +637,7 @@ static SQInteger SqBroadcastAnnounceEx(HSQUIRRELVM vm) } catch (const Sqrat::Exception & e) { - return sq_throwerror(vm, e.Message().c_str()); + return sq_throwerror(vm, e.what()); } // Attempt to generate the string value diff --git a/source/Routine.cpp b/source/Routine.cpp index 06e0a914..7ee3ecab 100644 --- a/source/Routine.cpp +++ b/source/Routine.cpp @@ -322,7 +322,7 @@ void Routine::Execute() } catch (const Sqrat::Exception & e) { - LogErr("Routine [%s] => Squirrel error [%s]", m_Tag.c_str(), e.Message().c_str()); + LogErr("Routine [%s] => Squirrel error [%s]", m_Tag.c_str(), e.what()); } catch (const std::exception & e) {