AnalysisFramework.formatErrors(): Support colored output and error IDs

This commit is contained in:
Kamil Śliwak 2023-08-04 13:32:32 +02:00
parent 6f3a379557
commit 6c1bcb9a81
2 changed files with 26 additions and 6 deletions

View File

@ -141,17 +141,30 @@ ErrorList AnalysisFramework::expectError(std::string const& _source, bool _warni
return sourceAndErrors.second;
}
string AnalysisFramework::formatErrors() const
string AnalysisFramework::formatErrors(
bool _colored,
bool _withErrorIds
) const
{
string message;
for (auto const& error: compiler().errors())
message += formatError(*error);
message += formatError(*error, _colored, _withErrorIds);
return message;
}
string AnalysisFramework::formatError(Error const& _error) const
string AnalysisFramework::formatError(
Error const& _error,
bool _colored,
bool _withErrorIds
) const
{
return SourceReferenceFormatter::formatErrorInformation(_error, *m_compiler);
return SourceReferenceFormatter::formatExceptionInformation(
_error,
_error.type(),
*m_compiler,
_colored,
_withErrorIds
);
}
ContractDefinition const* AnalysisFramework::retrieveContractByName(SourceUnit const& _source, string const& _name)

View File

@ -57,8 +57,15 @@ protected:
bool success(std::string const& _source);
langutil::ErrorList expectError(std::string const& _source, bool _warning = false, bool _allowMultiple = false);
std::string formatErrors() const;
std::string formatError(langutil::Error const& _error) const;
std::string formatErrors(
bool _colored = false,
bool _withErrorIds = false
) const;
std::string formatError(
langutil::Error const& _error,
bool _colored = false,
bool _withErrorIds = false
) const;
static ContractDefinition const* retrieveContractByName(SourceUnit const& _source, std::string const& _name);
static FunctionTypePointer retrieveFunctionBySignature(