Skip to content

Commit

Permalink
Add logic to check for blocking errors
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 committed Apr 5, 2024
1 parent 1155506 commit ddf7f46
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/Server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

#include <numeric>
#include <unordered_set>

#ifdef HAVE_PYBIND11
#include <pybind11/embed.h>
Expand Down Expand Up @@ -96,6 +97,17 @@ Server::Server(const ServerConfig &_config)

addResourcePaths();

auto hasBlockingErrors = [](const sdf::Errors &_errors) {
std::unordered_set<sdf::ErrorCode> nonBlockingErrors =
{sdf::ErrorCode::URI_LOOKUP};
for (auto &err : _errors)
{
if (nonBlockingErrors.find(err.Code()) == nonBlockingErrors.end())
return true;
}
return false;
};

sdf::Errors errors;

switch (_config.Source())
Expand Down Expand Up @@ -158,7 +170,7 @@ Server::Server(const ServerConfig &_config)
// a black screen (search for "Async resource download" in
// 'src/gui_main.cc'.
errors = sdfRoot.Load(filePath, sdfParserConfig);
if (errors.empty()) {
if (!hasBlockingErrors(errors)) {
if (sdfRoot.Model() == nullptr) {
this->dataPtr->sdfRoot = std::move(sdfRoot);
}
Expand All @@ -173,7 +185,7 @@ Server::Server(const ServerConfig &_config)
return;
}
world->AddModel(*sdfRoot.Model());
if (errors.empty()) {
if (!hasBlockingErrors(errors)) {
errors = this->dataPtr->sdfRoot.UpdateGraphs();
}
}
Expand All @@ -198,7 +210,8 @@ Server::Server(const ServerConfig &_config)
{
for (auto &err : errors)
gzerr << err << "\n";
return;
if (hasBlockingErrors(errors))
return;
}

// Add record plugin
Expand Down

0 comments on commit ddf7f46

Please sign in to comment.