mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-31 20:45:32 +00:00
Merge pull request #2752 from Assumeru/parsing-errors
Reset errorhandler context
This commit is contained in:
commit
328c3617b7
3 changed files with 26 additions and 1 deletions
|
@ -171,7 +171,7 @@ namespace MWScript
|
|||
{
|
||||
Compiler::Locals locals;
|
||||
|
||||
mErrorHandler.setContext(name2 + "[local variables]");
|
||||
const Compiler::ContextOverride override(mErrorHandler, name2 + "[local variables]");
|
||||
|
||||
std::istringstream stream (script->mScriptText);
|
||||
Compiler::QuickFileParser parser (mErrorHandler, mCompilerContext, locals);
|
||||
|
|
|
@ -62,4 +62,14 @@ namespace Compiler
|
|||
}
|
||||
|
||||
StreamErrorHandler::StreamErrorHandler() {}
|
||||
|
||||
ContextOverride::ContextOverride(StreamErrorHandler& handler, const std::string& context) : mHandler(handler), mContext(handler.mContext)
|
||||
{
|
||||
mHandler.setContext(context);
|
||||
}
|
||||
|
||||
ContextOverride::~ContextOverride()
|
||||
{
|
||||
mHandler.setContext(mContext);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,12 +7,14 @@
|
|||
|
||||
namespace Compiler
|
||||
{
|
||||
class ContextOverride;
|
||||
/// \brief Error handler implementation: Write errors into logging stream
|
||||
|
||||
class StreamErrorHandler : public ErrorHandler
|
||||
{
|
||||
std::string mContext;
|
||||
|
||||
friend class ContextOverride;
|
||||
// not implemented
|
||||
|
||||
StreamErrorHandler (const StreamErrorHandler&);
|
||||
|
@ -33,6 +35,19 @@ namespace Compiler
|
|||
StreamErrorHandler ();
|
||||
///< constructor
|
||||
};
|
||||
|
||||
class ContextOverride
|
||||
{
|
||||
StreamErrorHandler& mHandler;
|
||||
const std::string mContext;
|
||||
public:
|
||||
ContextOverride (StreamErrorHandler& handler, const std::string& context);
|
||||
|
||||
ContextOverride (const ContextOverride&) = delete;
|
||||
ContextOverride& operator= (const ContextOverride&) = delete;
|
||||
|
||||
~ContextOverride();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue