mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Handle Poco exceptions explicitly.
This commit is contained in:
parent
505650837e
commit
1f2b75ed26
@ -391,6 +391,10 @@ template < typename F, typename U, typename... Ts > SQInteger SqDynArgFwd(HSQUIR
|
||||
try
|
||||
{
|
||||
return SqDynArgImpl< U, Ts... >::Try(fn, vm);
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
return sq_throwerror(vm, e.displayText().c_str());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
|
@ -279,6 +279,11 @@ int32_t Controller::Run(const Guard & guard, const char * command)
|
||||
{
|
||||
return Exec(ctx);
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
// Tell the script callback to deal with the error
|
||||
SqError(CMDERR_EXECUTION_FAILED, _SC("Exceptions occurred during execution"), e.displayText().c_str());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
// Tell the script callback to deal with the error
|
||||
@ -425,6 +430,11 @@ int32_t Controller::Exec(Context & ctx)
|
||||
{
|
||||
ctx.mInstance->m_OnFail.Execute(ctx.mInvoker, result);
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
// Tell the script callback to deal with the error
|
||||
SqError(CMDERR_UNRESOLVED_FAILURE, _SC("Unable to resolve command failure"), e.displayText().c_str());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
// Tell the script callback to deal with the error
|
||||
@ -447,6 +457,11 @@ int32_t Controller::Exec(Context & ctx)
|
||||
{
|
||||
ctx.mInstance->m_OnFail.Execute(ctx.mInvoker, result);
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
// Tell the script callback to deal with the error
|
||||
SqError(CMDERR_UNRESOLVED_FAILURE, _SC("Unable to resolve command failure"), e.displayText().c_str());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
// Tell the script callback to deal with the error
|
||||
@ -462,6 +477,11 @@ int32_t Controller::Exec(Context & ctx)
|
||||
{
|
||||
ctx.mInstance->m_OnPost.Execute(ctx.mInvoker, result);
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
// Tell the script callback to deal with the error
|
||||
SqError(CMDERR_POST_PROCESSING_FAILED, _SC("Unable to complete command post processing"), e.displayText().c_str());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
// Tell the script callback to deal with the error
|
||||
|
@ -390,6 +390,11 @@ protected:
|
||||
{
|
||||
m_OnFail.Execute(type, msg, data);
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
// The debugger probably took care of reporting the details
|
||||
LogErr("Command error callback failed [%s]", e.displayText().c_str());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
// The debugger probably took care of reporting the details
|
||||
|
@ -17,6 +17,11 @@ namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#define SQMOD_CATCH_EVENT_EXCEPTION(action) /*
|
||||
*/ catch (const Poco::Exception & e) /*
|
||||
*/ { /*
|
||||
*/ LogErr("Program exception caught " action); /*
|
||||
*/ Logger::Get().DebugF(SqVM(), "%s", e.displayText().c_str()); /*
|
||||
*/ } /*
|
||||
*/ catch (const Sqrat::Exception & e) /*
|
||||
*/ { /*
|
||||
*/ LogErr("Squirrel exception caught " action); /*
|
||||
|
@ -1848,6 +1848,10 @@ void Core::EmitClientScriptData(int32_t player_id, const uint8_t * data, size_t
|
||||
// Get the object from the stack and store it
|
||||
o = Var< LightObj >(SqVM(), -1).value;
|
||||
}
|
||||
catch (const Poco::Exception & e)
|
||||
{
|
||||
STHROWF("{}", e.displayText()); // Re-package
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
STHROWF("{}", e.what()); // Re-package
|
||||
|
@ -198,7 +198,7 @@ SQInteger Routine::Create(HSQUIRRELVM vm)
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
return sq_throwerror(vm, "Unable to create the routine instance");
|
||||
return sq_throwerrorf(vm, "Unable to create the routine instance: %s", e.what());
|
||||
}
|
||||
// Prepare an object for the routine
|
||||
HSQOBJECT obj;
|
||||
@ -248,7 +248,7 @@ SQInteger Routine::Create(HSQUIRRELVM vm)
|
||||
// Clear extracted arguments
|
||||
inst.Clear();
|
||||
// Now it's safe to throw the error
|
||||
return sq_throwerror(vm, "Unable to create the routine instance");
|
||||
return sq_throwerrorf(vm, "Unable to create the routine instance: %s", e.what());
|
||||
}
|
||||
|
||||
// Alright, at this point we can initialize the slot
|
||||
|
@ -1348,6 +1348,10 @@ SQInteger Signal::SqEmit(HSQUIRRELVM vm)
|
||||
res = signal->Emit(vm, top);
|
||||
}
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
return sq_throwerror(vm, e.displayText().c_str());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
res = sq_throwerror(vm, e.what());
|
||||
@ -1388,6 +1392,10 @@ SQInteger Signal::SqQuery(HSQUIRRELVM vm)
|
||||
res = signal->Query(vm, top);
|
||||
}
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
return sq_throwerror(vm, e.displayText().c_str());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
res = sq_throwerror(vm, e.what());
|
||||
@ -1418,6 +1426,10 @@ SQInteger Signal::SqConsume(HSQUIRRELVM vm)
|
||||
res = signal->Consume(vm, top);
|
||||
}
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
return sq_throwerror(vm, e.displayText().c_str());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
res = sq_throwerror(vm, e.what());
|
||||
@ -1448,6 +1460,10 @@ SQInteger Signal::SqApprove(HSQUIRRELVM vm)
|
||||
res = signal->Approve(vm, top);
|
||||
}
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
return sq_throwerror(vm, e.displayText().c_str());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
res = sq_throwerror(vm, e.what());
|
||||
@ -1478,6 +1494,10 @@ SQInteger Signal::SqRequest(HSQUIRRELVM vm)
|
||||
res = signal->Request(vm, top);
|
||||
}
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
return sq_throwerror(vm, e.displayText().c_str());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
res = sq_throwerror(vm, e.what());
|
||||
|
@ -69,6 +69,11 @@ void DoReload()
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#define SQMOD_CATCH_EVENT_EXCEPTION(ev) /*
|
||||
*/ catch (const Poco::Exception & e) /*
|
||||
*/ { /*
|
||||
*/ LogErr("Squirrel exception caught (" #ev ") event"); /*
|
||||
*/ LogSInf("Message: %s", e.displayText().c_str()); /*
|
||||
*/ } /*
|
||||
*/ catch (const std::exception & e) /*
|
||||
*/ { /*
|
||||
*/ LogErr("Squirrel exception caught (" #ev ") event"); /*
|
||||
@ -982,6 +987,11 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * funcs, PluginCallback
|
||||
return SQMOD_FAILURE;
|
||||
}
|
||||
}
|
||||
catch (const Poco::Exception & e)
|
||||
{
|
||||
LogErr("Program exception caught during initialization");
|
||||
LogSInf("Message: %s", e.displayText().c_str());
|
||||
}
|
||||
catch (const Sqrat::Exception & e)
|
||||
{
|
||||
LogErr("Squirrel exception caught during initialization");
|
||||
|
@ -37,6 +37,10 @@ static SQInteger SqGetHash(HSQUIRRELVM vm)
|
||||
// Push the result on the stack
|
||||
Var< String >::push(vm, hex);
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
return sq_throwerrorf(vm, _SC("Failed to hash: %s"), e.displayText().c_str());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
return sq_throwerrorf(vm, _SC("Failed to hash: %s"), e.what());
|
||||
@ -69,6 +73,10 @@ static SQInteger SqEncodeBase32(HSQUIRRELVM vm)
|
||||
// Push the resulted string on the stack
|
||||
Var< String >::push(vm, out.str());
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
return sq_throwerrorf(vm, _SC("Failed to encode: %s"), e.displayText().c_str());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
return sq_throwerrorf(vm, _SC("Failed to encode: %s"), e.what());
|
||||
@ -102,6 +110,10 @@ static SQInteger SqDecodeBase32(HSQUIRRELVM vm)
|
||||
// Push the resulted string on the stack
|
||||
Var< String >::push(vm, out);
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
return sq_throwerrorf(vm, _SC("Failed to decode: %s"), e.displayText().c_str());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
return sq_throwerrorf(vm, _SC("Failed to decode: %s"), e.what());
|
||||
@ -134,6 +146,10 @@ static SQInteger SqEncodeBase64(HSQUIRRELVM vm)
|
||||
// Push the resulted string on the stack
|
||||
Var< String >::push(vm, out.str());
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
return sq_throwerrorf(vm, _SC("Failed to encode: %s"), e.displayText().c_str());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
return sq_throwerrorf(vm, _SC("Failed to encode: %s"), e.what());
|
||||
@ -167,6 +183,10 @@ static SQInteger SqDecodeBase64(HSQUIRRELVM vm)
|
||||
// Push the resulted string on the stack
|
||||
Var< String >::push(vm, out);
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
return sq_throwerrorf(vm, _SC("Failed to decode: %s"), e.displayText().c_str());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
return sq_throwerrorf(vm, _SC("Failed to decode: %s"), e.what());
|
||||
@ -195,6 +215,10 @@ static SQInteger SqGetCRC32(HSQUIRRELVM vm)
|
||||
// Push the result on the stack
|
||||
sq_pushinteger(vm, static_cast< SQInteger >(c.checksum()));
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
return sq_throwerrorf(vm, _SC("Failed to compute checksum: %s"), e.displayText().c_str());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
return sq_throwerrorf(vm, _SC("Failed to compute checksum: %s"), e.what());
|
||||
@ -223,6 +247,10 @@ static SQInteger SqGetADLER32(HSQUIRRELVM vm)
|
||||
// Push the result on the stack
|
||||
sq_pushinteger(vm, static_cast< SQInteger >(c.checksum()));
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
return sq_throwerrorf(vm, _SC("Failed to compute checksum: %s"), e.displayText().c_str());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
return sq_throwerrorf(vm, _SC("Failed to compute checksum: %s"), e.what());
|
||||
|
@ -122,6 +122,8 @@ template <class R> struct SqGlobal {
|
||||
#endif
|
||||
try {
|
||||
return SqGlobalProxy<R>::template Run<A...>(vm, startIdx);
|
||||
} catch (const Poco::Exception& e) {
|
||||
return sq_throwerror(vm, e.displayText().c_str());
|
||||
} catch (const std::exception& e) {
|
||||
return sq_throwerror(vm, e.what());
|
||||
} catch (...) {
|
||||
@ -148,6 +150,8 @@ template <class R> struct SqGlobal<R&> {
|
||||
#endif
|
||||
try {
|
||||
return SqGlobalProxy<R&>::template Run<A...>(vm, startIdx);
|
||||
} catch (const Poco::Exception& e) {
|
||||
return sq_throwerror(vm, e.displayText().c_str());
|
||||
} catch (const std::exception& e) {
|
||||
return sq_throwerror(vm, e.what());
|
||||
} catch (...) {
|
||||
@ -174,6 +178,8 @@ template <> struct SqGlobal<void> {
|
||||
#endif
|
||||
try {
|
||||
return SqGlobalProxy<void>::Run<A...>(vm, startIdx);
|
||||
} catch (const Poco::Exception& e) {
|
||||
return sq_throwerror(vm, e.displayText().c_str());
|
||||
} catch (const std::exception& e) {
|
||||
return sq_throwerror(vm, e.what());
|
||||
} catch (...) {
|
||||
|
@ -152,6 +152,8 @@ template <class C,class R> struct SqMember {
|
||||
#endif
|
||||
try {
|
||||
return SqMemberProxy<C, R>:: template Run<A...>(vm);
|
||||
} catch (const Poco::Exception& e) {
|
||||
return sq_throwerror(vm, e.displayText().c_str());
|
||||
} catch (const std::exception& e) {
|
||||
return sq_throwerror(vm, e.what());
|
||||
} catch (...) {
|
||||
@ -171,6 +173,8 @@ template <class C,class R> struct SqMember {
|
||||
#endif
|
||||
try {
|
||||
return SqMemberProxy<C,R>::template RunC<A...>(vm);
|
||||
} catch (const Poco::Exception& e) {
|
||||
return sq_throwerror(vm, e.displayText().c_str());
|
||||
} catch (const std::exception& e) {
|
||||
return sq_throwerror(vm, e.what());
|
||||
} catch (...) {
|
||||
@ -197,6 +201,8 @@ template <class C, class R> struct SqMember<C,R&> {
|
||||
#endif
|
||||
try {
|
||||
return SqMemberProxy<C,R&>::template Run<A...>(vm);
|
||||
} catch (const Poco::Exception& e) {
|
||||
return sq_throwerror(vm, e.displayText().c_str());
|
||||
} catch (const std::exception& e) {
|
||||
return sq_throwerror(vm, e.what());
|
||||
} catch (...) {
|
||||
@ -216,6 +222,8 @@ template <class C, class R> struct SqMember<C,R&> {
|
||||
#endif
|
||||
try {
|
||||
return SqMemberProxy<C,R&>::template RunC<A...>(vm);
|
||||
} catch (const Poco::Exception& e) {
|
||||
return sq_throwerror(vm, e.displayText().c_str());
|
||||
} catch (const std::exception& e) {
|
||||
return sq_throwerror(vm, e.what());
|
||||
} catch (...) {
|
||||
@ -243,6 +251,8 @@ template <class C> struct SqMember<C, void> {
|
||||
#endif
|
||||
try {
|
||||
return SqMemberProxy<C, void>::template Run<A...>(vm);
|
||||
} catch (const Poco::Exception& e) {
|
||||
return sq_throwerror(vm, e.displayText().c_str());
|
||||
} catch (const std::exception& e) {
|
||||
return sq_throwerror(vm, e.what());
|
||||
} catch (...) {
|
||||
@ -262,6 +272,8 @@ template <class C> struct SqMember<C, void> {
|
||||
#endif
|
||||
try {
|
||||
return SqMemberProxy<C,void>::template RunC<A...>(vm);
|
||||
} catch (const Poco::Exception& e) {
|
||||
return sq_throwerror(vm, e.displayText().c_str());
|
||||
} catch (const std::exception& e) {
|
||||
return sq_throwerror(vm, e.what());
|
||||
} catch (...) {
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include <exception>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <Poco/Exception.h>
|
||||
|
||||
namespace Sqrat {
|
||||
|
||||
#if defined(__GNUC__)
|
||||
|
Loading…
Reference in New Issue
Block a user