diff options
author | Ben Smith <binji@chromium.org> | 2018-09-03 13:08:23 -0700 |
---|---|---|
committer | Ben Smith <binjimin@gmail.com> | 2018-09-04 15:13:23 -0700 |
commit | e0719fe0fe504c497d9fb7510fe68499c08179f4 (patch) | |
tree | 1e2f3d3b4ac76b239bb75a6f819d8fd1f1cc8050 /src/binary-reader-objdump.cc | |
parent | b4125e90c70a6b1bef4480e33f3c838ab4c7cfcb (diff) | |
download | wabt-e0719fe0fe504c497d9fb7510fe68499c08179f4.tar.gz wabt-e0719fe0fe504c497d9fb7510fe68499c08179f4.tar.bz2 wabt-e0719fe0fe504c497d9fb7510fe68499c08179f4.zip |
Replace ErrorHandler with Errors and FormatErrors*
`ErrorHandler` complicated all error handling in wabt, since it was
callback-based. Callbacks would be useful if we ever wanted to change
behavior when an error occurred, but instead all that the handler ever
did was write the errors to stdout/stderr or to a buffer.
This change adds a new class `Error`, which contains an `ErrorLevel`, a
`Location` and an error message. It also replaces ErrorHandler with
`Errors` (a typedef for `std::vector<Error>`), and adds a couple of
functions that can format a list of `Errors` for output:
`FormatErrorsTo{String,File}`.
Diffstat (limited to 'src/binary-reader-objdump.cc')
-rw-r--r-- | src/binary-reader-objdump.cc | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc index cec37772..420940f5 100644 --- a/src/binary-reader-objdump.cc +++ b/src/binary-reader-objdump.cc @@ -38,7 +38,7 @@ class BinaryReaderObjdumpBase : public BinaryReaderNop { ObjdumpOptions* options, ObjdumpState* state); - bool OnError(ErrorLevel, const char* message) override; + bool OnError(const Error&) override; Result BeginModule(uint32_t version) override; Result BeginSection(BinarySection section_type, Offset size) override; @@ -86,8 +86,7 @@ Result BinaryReaderObjdumpBase::BeginSection(BinarySection section_code, return Result::Ok; } -bool BinaryReaderObjdumpBase::OnError(ErrorLevel error_level, - const char* message) { +bool BinaryReaderObjdumpBase::OnError(const Error&) { // Tell the BinaryReader that this error is "handled" for all passes other // than the prepass. When the error is handled the default message will be // suppressed. |