Suppress exceptions in Sensor's destructor

This commit is contained in:
nsubiron 2018-10-22 15:59:43 +02:00
parent e52f780bd5
commit bd15ef11ea
3 changed files with 23 additions and 9 deletions

View File

@ -9,6 +9,8 @@
#include "carla/Logging.h"
#include "carla/client/detail/Client.h"
#include <exception>
namespace carla {
namespace client {
@ -20,7 +22,11 @@ namespace client {
GetDisplayId());
}
if (_is_listening) {
Stop();
try {
Stop();
} catch (const std::exception &e) {
log_error("excetion trying to stop sensor:", GetDisplayId(), ':', e.what());
}
}
}

View File

@ -12,10 +12,16 @@ namespace carla {
namespace client {
namespace detail {
std::string ActorState::GetDisplayId() const {
using namespace std::string_literals;
return "Actor "s + std::to_string(GetId()) + " (" + GetTypeId() + ')';
}
ActorState::ActorState(rpc::Actor description, Episode episode)
: _description(std::move(description)),
_episode(std::move(episode)),
_display_id([](const auto &desc) {
using namespace std::string_literals;
return
"Actor "s +
std::to_string(desc.id) +
" (" + desc.description.id + ')';
}(_description)) {}
} // namespace detail
} // namespace client

View File

@ -27,7 +27,9 @@ namespace detail {
return _description.description.id;
}
std::string GetDisplayId() const;
const std::string &GetDisplayId() const {
return _display_id;
}
World GetWorld() const {
return _episode;
@ -51,13 +53,13 @@ namespace detail {
friend class detail::Client;
ActorState(rpc::Actor description, Episode episode)
: _description(std::move(description)),
_episode(std::move(episode)) {}
ActorState(rpc::Actor description, Episode episode);
rpc::Actor _description;
Episode _episode;
std::string _display_id;
};
} // namespace detail