-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
event_status.cc
33 lines (25 loc) · 1.03 KB
/
event_status.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "drake/systems/framework/event_status.h"
#include <stdexcept>
#include <fmt/format.h>
#include "drake/common/nice_type_name.h"
#include "drake/systems/framework/system_base.h"
namespace drake {
namespace systems {
void EventStatus::ThrowOnFailure(const char* function_name) const {
if (!failed()) return;
DRAKE_THROW_UNLESS(function_name != nullptr);
/* Attempt to identify the relevant subsystem in human-readable terms. If no
subsystem was provided we just call it "System". Otherwise, we obtain its
type and its name and call it "type system 'name'", e.g.
"MultibodyPlant<double> system 'my_plant'". */
const std::string system_id =
system() == nullptr
? "System"
: fmt::format("{} system '{}'", system()->GetSystemType(),
system()->GetSystemPathname());
throw std::runtime_error(
fmt::format("{}(): An event handler in {} failed with message: \"{}\".",
function_name, system_id, message()));
}
} // namespace systems
} // namespace drake