Skip to content

Commit

Permalink
Restore message() method for errors loading IR
Browse files Browse the repository at this point in the history
  • Loading branch information
jdorn-gt committed Feb 24, 2022
1 parent 0a9aa98 commit 83cd84d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions include/gtirb/ErrorOr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ namespace gtirb {

/// A small struct to hold an error code
/// along with a string holding additional details
struct ErrorInfo {
struct GTIRB_EXPORT_API ErrorInfo {
std::error_code ErrorCode;
std::string Msg;
ErrorInfo() = default;
ErrorInfo(const std::error_code& EC, const std::string& S)
: ErrorCode(EC), Msg(S){};
std::string asString();
std::string message() const;
};

template <typename CharT, typename Traits>
Expand Down
4 changes: 2 additions & 2 deletions src/ByteInterval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ ErrorOr<ByteInterval*> ByteInterval::fromProtobuf(Context& C,
case proto::Block::ValueCase::kCode: {
auto B = CodeBlock::fromProtobuf(C, ProtoBlock.code());
if (!B) {
Err.Msg += "\n" + B.getError().asString();
Err.Msg += "\n" + B.getError().message();
return Err;
}
BI->addBlock(ProtoBlock.offset(), *B);
} break;
case proto::Block::ValueCase::kData: {
auto B = DataBlock::fromProtobuf(C, ProtoBlock.data());
if (!B) {
Err.Msg += "\n" + B.getError().asString();
Err.Msg += "\n" + B.getError().message();
return Err;
}
BI->addBlock(ProtoBlock.offset(), *B);
Expand Down
2 changes: 1 addition & 1 deletion src/ErrorOr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace gtirb {

std::string ErrorInfo::asString() {
std::string ErrorInfo::message() const {
std::stringstream Stream;
Stream << *this;
return Stream.str();
Expand Down
2 changes: 1 addition & 1 deletion src/IR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ ErrorOr<IR*> IR::fromProtobuf(Context& C, const MessageType& Message) {
auto M = Module::fromProtobuf(C, Elt);
if (!M) {
ErrorInfo Err{load_error::CorruptModule, "#" + std::to_string(i)};
Err.Msg += "\n" + M.getError().asString();
Err.Msg += "\n" + M.getError().message();
return Err;
}
I->addModule(*M);
Expand Down
6 changes: 3 additions & 3 deletions src/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,23 @@ ErrorOr<Module*> Module::fromProtobuf(Context& C, const MessageType& Message) {
for (const auto& Elt : Message.proxies()) {
auto PB = ProxyBlock::fromProtobuf(C, Elt);
if (!PB) {
Problem.Msg += "\n" + PB.getError().asString();
Problem.Msg += "\n" + PB.getError().message();
return Problem;
}
M->addProxyBlock(*PB);
}
for (const auto& Elt : Message.sections()) {
auto S = Section::fromProtobuf(C, Elt);
if (!S) {
Problem.Msg += "\n" + S.getError().asString();
Problem.Msg += "\n" + S.getError().message();
return Problem;
}
M->addSection(*S);
}
for (const auto& Elt : Message.symbols()) {
auto S = Symbol::fromProtobuf(C, Elt);
if (!S) {
Problem.Msg += "\n" + S.getError().asString();
Problem.Msg += "\n" + S.getError().message();
return Problem;
}
M->addSymbol(*S);
Expand Down
2 changes: 1 addition & 1 deletion src/Section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ ErrorOr<Section*> Section::fromProtobuf(Context& C,
if (!BI) {
ErrorInfo err{IR::load_error::CorruptSection,
"Could not load section" + Message.name() + "\n" +
BI.getError().asString()};
BI.getError().message()};
return err;
}
S->addByteInterval(*BI);
Expand Down

0 comments on commit 83cd84d

Please sign in to comment.