@@ -65,7 +65,7 @@ AnsiColorized SourceReferenceFormatter::frameColored() const
65
65
return AnsiColorized (m_stream, m_colored, {BOLD, BLUE});
66
66
}
67
67
68
- AnsiColorized SourceReferenceFormatter::errorColored (Error::Severity _severity) const
68
+ AnsiColorized SourceReferenceFormatter::errorColored (std::ostream& _stream, bool _colored, Error::Severity _severity)
69
69
{
70
70
// We used to color messages of any severity as errors so this seems like a good default
71
71
// for cases where severity cannot be determined.
@@ -78,12 +78,12 @@ AnsiColorized SourceReferenceFormatter::errorColored(Error::Severity _severity)
78
78
case Error::Severity::Info: textColor = WHITE; break ;
79
79
}
80
80
81
- return AnsiColorized (m_stream, m_colored , {BOLD, textColor});
81
+ return AnsiColorized (_stream, _colored , {BOLD, textColor});
82
82
}
83
83
84
- AnsiColorized SourceReferenceFormatter::messageColored () const
84
+ AnsiColorized SourceReferenceFormatter::messageColored (std::ostream& _stream, bool _colored)
85
85
{
86
- return AnsiColorized (m_stream, m_colored , {BOLD, WHITE});
86
+ return AnsiColorized (_stream, _colored , {BOLD, WHITE});
87
87
}
88
88
89
89
AnsiColorized SourceReferenceFormatter::secondaryColored () const
@@ -175,14 +175,26 @@ void SourceReferenceFormatter::printSourceLocation(SourceReference const& _ref)
175
175
}
176
176
}
177
177
178
- void SourceReferenceFormatter::printExceptionInformation (SourceReferenceExtractor::Message const & _msg)
178
+ void SourceReferenceFormatter::printPrimaryMessage (
179
+ std::ostream& _stream,
180
+ std::string _message,
181
+ std::variant<Error::Type, Error::Severity> _typeOrSeverity,
182
+ std::optional<ErrorId> _errorId,
183
+ bool _colored,
184
+ bool _withErrorIds
185
+ )
179
186
{
180
- errorColored (Error::errorSeverityOrType (_msg._typeOrSeverity )) << Error::formatTypeOrSeverity (_msg._typeOrSeverity );
187
+ errorColored (_stream, _colored, Error::errorSeverityOrType (_typeOrSeverity)) << Error::formatTypeOrSeverity (_typeOrSeverity);
188
+
189
+ if (_withErrorIds && _errorId.has_value ())
190
+ errorColored (_stream, _colored, Error::errorSeverityOrType (_typeOrSeverity)) << " (" << _errorId.value ().error << " )" ;
181
191
182
- if (m_withErrorIds && _msg. errorId . has_value ())
183
- errorColored ( Error::errorSeverityOrType (_msg. _typeOrSeverity )) << " ( " << _msg. errorId . value (). error << " ) " ;
192
+ messageColored (_stream, _colored) << " : " << _message << ' \n ' ;
193
+ }
184
194
185
- messageColored () << " : " << _msg.primary .message << ' \n ' ;
195
+ void SourceReferenceFormatter::printExceptionInformation (SourceReferenceExtractor::Message const & _msg)
196
+ {
197
+ printPrimaryMessage (m_stream, _msg.primary .message , _msg._typeOrSeverity , _msg.errorId , m_colored, m_withErrorIds);
186
198
printSourceLocation (_msg.primary );
187
199
188
200
for (auto const & secondary: _msg.secondary )
0 commit comments