- use a separate exception type for reporting errors from FraggleScript.

CRecoverableError is used in other parts as well and it might create interference.
This commit is contained in:
Christoph Oelckers 2016-12-02 16:56:50 +01:00
parent f9441cd9d9
commit 967f6c0269
4 changed files with 27 additions and 5 deletions

View file

@ -2014,13 +2014,13 @@ void FParser::SF_CeilingTexture(void)
void FParser::SF_ChangeHubLevel(void) void FParser::SF_ChangeHubLevel(void)
{ {
I_Error("FS hub system permanently disabled\n"); script_error("FS hub system permanently disabled\n");
} }
// for start map: start new game on a particular skill // for start map: start new game on a particular skill
void FParser::SF_StartSkill(void) void FParser::SF_StartSkill(void)
{ {
I_Error("startskill is not supported by this implementation!\n"); script_error("startskill is not supported by this implementation!\n");
} }
//========================================================================== //==========================================================================

View file

@ -113,7 +113,7 @@ void FParser::NextToken()
} }
if(!Section) if(!Section)
{ {
I_Error("section not found!\n"); script_error("section not found!\n");
return; return;
} }
} }
@ -708,6 +708,18 @@ void FParser::EvaluateExpression(svalue_t &result, int start, int stop)
// //
//========================================================================== //==========================================================================
void FS_Error(const char *error, ...)
{
va_list argptr;
char errortext[MAX_ERRORTEXT];
va_start(argptr, error);
myvsnprintf(errortext, MAX_ERRORTEXT, error, argptr);
va_end(argptr);
throw CFraggleScriptError(errortext);
}
void FParser::ErrorMessage(FString msg) void FParser::ErrorMessage(FString msg)
{ {
int linenum = 0; int linenum = 0;
@ -721,7 +733,7 @@ void FParser::ErrorMessage(FString msg)
} }
//lineinfo.Format("Script %d, line %d: ", Script->scriptnum, linenum); //lineinfo.Format("Script %d, line %d: ", Script->scriptnum, linenum);
I_Error("Script %d, line %d: %s", Script->scriptnum, linenum, msg.GetChars()); FS_Error("Script %d, line %d: %s", Script->scriptnum, linenum, msg.GetChars());
} }
//========================================================================== //==========================================================================

View file

@ -251,7 +251,7 @@ void DFsScript::ParseScript(char *position)
FParser parse(this); FParser parse(this);
parse.Run(position, data, data + len); parse.Run(position, data, data + len);
} }
catch (CRecoverableError &err) catch (CFraggleScriptError &err)
{ {
Printf ("%s\n", err.GetMessage()); Printf ("%s\n", err.GetMessage());
} }

View file

@ -41,12 +41,22 @@
#include "p_lnspec.h" #include "p_lnspec.h"
#include "m_fixed.h" #include "m_fixed.h"
#include "actor.h" #include "actor.h"
#include "doomerrors.h"
#ifdef _MSC_VER #ifdef _MSC_VER
// This pragma saves 8kb of wasted code. // This pragma saves 8kb of wasted code.
#pragma pointers_to_members( full_generality, single_inheritance ) #pragma pointers_to_members( full_generality, single_inheritance )
#endif #endif
class CFraggleScriptError : public CDoomError
{
public:
CFraggleScriptError() : CDoomError() {}
CFraggleScriptError(const char *message) : CDoomError(message) {}
};
class DRunningScript; class DRunningScript;