Catch FatalError in StandardCompiler

This commit is contained in:
Alex Beregszaszi 2017-07-26 22:52:11 +01:00
parent a605e4eb95
commit fb7eec8dd5

View File

@ -285,6 +285,7 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
)); ));
} }
} }
/// This is only thrown in a very few locations.
catch (Error const& _error) catch (Error const& _error)
{ {
if (_error.type() == Error::Type::DocstringParsingError) if (_error.type() == Error::Type::DocstringParsingError)
@ -300,10 +301,20 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
false, false,
_error.typeName(), _error.typeName(),
"general", "general",
"", "Uncaught error: ",
scannerFromSourceName scannerFromSourceName
)); ));
} }
/// This should not be leaked from compile().
catch (FatalError const& _exception)
{
errors.append(formatError(
false,
"FatalError",
"general",
"Uncaught fatal error: " + boost::diagnostic_information(_exception)
));
}
catch (CompilerError const& _exception) catch (CompilerError const& _exception)
{ {
errors.append(formatErrorWithException( errors.append(formatErrorWithException(
@ -322,7 +333,8 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
false, false,
"InternalCompilerError", "InternalCompilerError",
"general", "general",
"Internal compiler error (" + _exception.lineInfo() + ")", scannerFromSourceName "Internal compiler error (" + _exception.lineInfo() + ")",
scannerFromSourceName
)); ));
} }
catch (UnimplementedFeatureError const& _exception) catch (UnimplementedFeatureError const& _exception)
@ -333,7 +345,8 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
"UnimplementedFeatureError", "UnimplementedFeatureError",
"general", "general",
"Unimplemented feature (" + _exception.lineInfo() + ")", "Unimplemented feature (" + _exception.lineInfo() + ")",
scannerFromSourceName)); scannerFromSourceName
));
} }
catch (Exception const& _exception) catch (Exception const& _exception)
{ {