summaryrefslogtreecommitdiff
path: root/src/error-handler.cc
diff options
context:
space:
mode:
authorBen Smith <binjimin@gmail.com>2018-05-16 19:21:19 -0700
committerGitHub <noreply@github.com>2018-05-16 19:21:19 -0700
commit1fec702978b82945f5e6097f765d505f25f30097 (patch)
treec1df59bd7fdfc8609c1eac150e3dd5a85854c1c7 /src/error-handler.cc
parentdd7663d78bf483308cd8d70d114748321f2cd61f (diff)
downloadwabt-1fec702978b82945f5e6097f765d505f25f30097.tar.gz
wabt-1fec702978b82945f5e6097f765d505f25f30097.tar.bz2
wabt-1fec702978b82945f5e6097f765d505f25f30097.zip
Print "warning" for ignored custom section errors (#843)
The previous message said "error", which makes it look like the output is not created, so change the message to "warning" instead. The error handling code is pretty ugly and can use a refactor, but that would be a much larger change.
Diffstat (limited to 'src/error-handler.cc')
-rw-r--r--src/error-handler.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/error-handler.cc b/src/error-handler.cc
index 7c70281f..49e8d818 100644
--- a/src/error-handler.cc
+++ b/src/error-handler.cc
@@ -23,7 +23,8 @@ namespace wabt {
ErrorHandler::ErrorHandler(Location::Type location_type)
: location_type_(location_type) {}
-std::string ErrorHandler::DefaultErrorMessage(const Color& color,
+std::string ErrorHandler::DefaultErrorMessage(ErrorLevel error_level,
+ const Color& color,
const Location& loc,
const std::string& error,
const std::string& source_line,
@@ -46,7 +47,8 @@ std::string ErrorHandler::DefaultErrorMessage(const Color& color,
}
result += color.MaybeRedCode();
- result += "error: ";
+ result += GetErrorLevelName(error_level);
+ result += ": ";
result += color.MaybeDefaultCode();
result += error;
@@ -89,15 +91,17 @@ ErrorHandlerFile::ErrorHandlerFile(Location::Type location_type,
source_line_max_length_(source_line_max_length),
color_(file) {}
-bool ErrorHandlerFile::OnError(const Location& loc,
+bool ErrorHandlerFile::OnError(ErrorLevel level,
+ const Location& loc,
const std::string& error,
const std::string& source_line,
size_t source_line_column_offset) {
PrintErrorHeader();
int indent = header_.empty() ? 0 : 2;
- std::string message = DefaultErrorMessage(color_, loc, error, source_line,
- source_line_column_offset, indent);
+ std::string message =
+ DefaultErrorMessage(level, color_, loc, error, source_line,
+ source_line_column_offset, indent);
fwrite(message.data(), 1, message.size(), file_);
return true;
}
@@ -127,11 +131,12 @@ ErrorHandlerBuffer::ErrorHandlerBuffer(Location::Type location_type,
source_line_max_length_(source_line_max_length),
color_(nullptr, false) {}
-bool ErrorHandlerBuffer::OnError(const Location& loc,
+bool ErrorHandlerBuffer::OnError(ErrorLevel level,
+ const Location& loc,
const std::string& error,
const std::string& source_line,
size_t source_line_column_offset) {
- buffer_ += DefaultErrorMessage(color_, loc, error, source_line,
+ buffer_ += DefaultErrorMessage(level, color_, loc, error, source_line,
source_line_column_offset, 0);
return true;
}