summaryrefslogtreecommitdiffstats
path: root/yql/essentials/parser/common/error.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'yql/essentials/parser/common/error.cpp')
-rw-r--r--yql/essentials/parser/common/error.cpp36
1 files changed, 15 insertions, 21 deletions
diff --git a/yql/essentials/parser/common/error.cpp b/yql/essentials/parser/common/error.cpp
index 9fad2892213..b6b087631c7 100644
--- a/yql/essentials/parser/common/error.cpp
+++ b/yql/essentials/parser/common/error.cpp
@@ -14,35 +14,29 @@ namespace NAST {
}
void IErrorCollector::Error(ui32 line, ui32 col, const TString& message) {
- if (NumErrors_ + 1 == MaxErrors_) {
- AddError(0, 0, "Too many errors");
- ++NumErrors_;
- }
-
- if (NumErrors_ >= MaxErrors_) {
- ythrow TTooManyErrors() << "Too many errors";
- }
-
+ GuardTooManyErrors();
AddError(line, col, message);
++NumErrors_;
}
- TErrorOutput::TErrorOutput(IOutputStream& err, const TString& name, size_t maxErrors)
- : IErrorCollector(maxErrors)
- , Err(err)
- , Name(name)
- {
+ void IErrorCollector::Report(NYql::TIssue&& issue) {
+ GuardTooManyErrors();
+ bool isError = issue.GetSeverity() >= NYql::TSeverityIds::S_WARNING;
+ AddIssue(std::forward<NYql::TIssue>(issue));
+ if (isError) {
+ ++NumErrors_;
+ }
}
- TErrorOutput::~TErrorOutput()
- {
- }
+ void IErrorCollector::GuardTooManyErrors() {
+ if (NumErrors_ + 1 == MaxErrors_) {
+ AddError(0, 0, "Too many errors");
+ ++NumErrors_;
+ }
- void TErrorOutput::AddError(ui32 line, ui32 col, const TString& message) {
- if (!Name.empty()) {
- Err << "Query " << Name << ": ";
+ if (NumErrors_ >= MaxErrors_) {
+ ythrow TTooManyErrors() << "Too many errors";
}
- Err << "Line " << line << " column " << col << " error: " << message;
}
} // namespace NAST