mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-07 08:15:34 +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;
|
Compiler::Locals locals;
|
||||||
|
|
||||||
mErrorHandler.setContext(name2 + "[local variables]");
|
const Compiler::ContextOverride override(mErrorHandler, name2 + "[local variables]");
|
||||||
|
|
||||||
std::istringstream stream (script->mScriptText);
|
std::istringstream stream (script->mScriptText);
|
||||||
Compiler::QuickFileParser parser (mErrorHandler, mCompilerContext, locals);
|
Compiler::QuickFileParser parser (mErrorHandler, mCompilerContext, locals);
|
||||||
|
|
|
@ -62,4 +62,14 @@ namespace Compiler
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamErrorHandler::StreamErrorHandler() {}
|
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
|
namespace Compiler
|
||||||
{
|
{
|
||||||
|
class ContextOverride;
|
||||||
/// \brief Error handler implementation: Write errors into logging stream
|
/// \brief Error handler implementation: Write errors into logging stream
|
||||||
|
|
||||||
class StreamErrorHandler : public ErrorHandler
|
class StreamErrorHandler : public ErrorHandler
|
||||||
{
|
{
|
||||||
std::string mContext;
|
std::string mContext;
|
||||||
|
|
||||||
|
friend class ContextOverride;
|
||||||
// not implemented
|
// not implemented
|
||||||
|
|
||||||
StreamErrorHandler (const StreamErrorHandler&);
|
StreamErrorHandler (const StreamErrorHandler&);
|
||||||
|
@ -33,6 +35,19 @@ namespace Compiler
|
||||||
StreamErrorHandler ();
|
StreamErrorHandler ();
|
||||||
///< constructor
|
///< 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
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue