Skip to content

Commit

Permalink
removed calls to createStringError
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariel Davis authored and jdorn-gt committed Feb 24, 2022
1 parent 8f1ebe8 commit ed377aa
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 17 deletions.
7 changes: 3 additions & 4 deletions src/ByteInterval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ ErrorOr<ByteInterval*> ByteInterval::fromProtobuf(Context& C,
if (A)
ss << "@ " << *A;

return createStringError(IR::load_error::BadUUID, ss.str());
return {IR::load_error::BadUUID, ss.str()};
}

ByteInterval* BI = ByteInterval::Create(
Expand All @@ -151,9 +151,8 @@ ErrorOr<ByteInterval*> ByteInterval::fromProtobuf(Context& C,
BI->addBlock(ProtoBlock.offset(), *B);
} break;
default: {
return createStringError(
IR::load_error::CorruptFile,
"unknown Block::ValueCase in ByteInterval::fromProtobuf");
return {IR::load_error::CorruptFile,
"unknown Block::ValueCase in ByteInterval::fromProtobuf"};
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/CodeBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ErrorOr<CodeBlock*> CodeBlock::fromProtobuf(Context& C,
// set its parent at the same time.
UUID Id;
if (!uuidFromBytes(Message.uuid(), Id))
return createStringError(IR::load_error::BadUUID, "Cannot load code block");
return {IR::load_error::BadUUID, "Cannot load code block"};

return CodeBlock::Create(C, Message.size(), Message.decode_mode(), Id);
}
Expand Down
2 changes: 1 addition & 1 deletion src/DataBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ErrorOr<DataBlock*> DataBlock::fromProtobuf(Context& C,
const MessageType& Message) {
UUID Id;
if (!uuidFromBytes(Message.uuid(), Id))
return createStringError(IR::load_error::BadUUID, "Cannot load DataBlock");
return {IR::load_error::BadUUID, "Cannot load DataBlock"};

// Because we do not have an offset, we cannot create the data block and
// set its parent at the same time.
Expand Down
4 changes: 2 additions & 2 deletions src/IR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void IR::toProtobuf(MessageType* Message) const {
ErrorOr<IR*> IR::fromProtobuf(Context& C, const MessageType& Message) {
UUID Id;
if (!uuidFromBytes(Message.uuid(), Id))
return createStringError(load_error::CorruptFile, "Cannot load IR");
return {load_error::CorruptFile, "Cannot load IR"};

auto* I = IR::Create(C, Id);
int i = 0;
Expand All @@ -176,7 +176,7 @@ ErrorOr<IR*> IR::fromProtobuf(Context& C, const MessageType& Message) {
if (I->Version != GTIRB_PROTOBUF_VERSION) {
std::stringstream ss;
ss << I->Version << "; expected version " << GTIRB_PROTOBUF_VERSION;
return createStringError(load_error::IncorrectVersion, ss.str());
return {load_error::IncorrectVersion, ss.str()};
}
return I;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ static void nodeMapFromProtobuf(Context& C, std::map<T, U*>& Values,
ErrorOr<Module*> Module::fromProtobuf(Context& C, const MessageType& Message) {
UUID Id;
if (!uuidFromBytes(Message.uuid(), Id))
return createStringError(IR::load_error::BadUUID, "Cannot load module");
return {IR::load_error::BadUUID, "Cannot load module"};

auto Problem = createStringError(IR::load_error::CorruptModule,
"Cannot load module " + Message.name());
ErrorInfo Problem{IR::load_error::CorruptModule,
"Cannot load module " + Message.name()};

Module* M = Module::Create(C, Message.name(), Id);
M->BinaryPath = Message.binary_path();
Expand Down
3 changes: 1 addition & 2 deletions src/ProxyBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ ErrorOr<ProxyBlock*> ProxyBlock::fromProtobuf(Context& C,
const MessageType& Message) {
UUID Id;
if (!uuidFromBytes(Message.uuid(), Id))
return createStringError(IR::load_error::BadUUID,
"Could not create proxy block");
return {IR::load_error::BadUUID, "Could not create proxy block"};

return Create(C, Id);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ ErrorOr<Section*> Section::fromProtobuf(Context& C,
const MessageType& Message) {
UUID Id;
if (!uuidFromBytes(Message.uuid(), Id))
return createStringError(IR::load_error::BadUUID, "Could not load section");
return {IR::load_error::BadUUID, "Could not load section"};

auto* S = Section::Create(C, Message.name(), Id);
for (int I = 0, E = Message.section_flags_size(); I != E; ++I) {
Expand All @@ -91,8 +91,8 @@ ErrorOr<Section*> Section::fromProtobuf(Context& C,
for (const auto& ProtoInterval : Message.byte_intervals()) {
auto BI = ByteInterval::fromProtobuf(C, ProtoInterval);
if (!BI) {
auto err = createStringError(IR::load_error::CorruptSection,
"Could not load section" + Message.name());
ErrorInfo err{IR::load_error::CorruptSection,
"Could not load section" + Message.name()};
return joinErrors(err, BI.getError());
}
S->addByteInterval(*BI);
Expand Down
2 changes: 1 addition & 1 deletion src/Symbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void Symbol::toProtobuf(MessageType* Message) const {
ErrorOr<Symbol*> Symbol::fromProtobuf(Context& C, const MessageType& Message) {
UUID Id;
if (!uuidFromBytes(Message.uuid(), Id))
return createStringError(IR::load_error::BadUUID, "could not load Symbol");
return {IR::load_error::BadUUID, "could not load Symbol"};

Symbol* S = Symbol::Create(C, Message.name(), Message.at_end(), Id);

Expand Down

0 comments on commit ed377aa

Please sign in to comment.