Is your feature request related to a problem? Please describe.
When an error message incorporates a TypeSafeIndex<Tag> (e.g., BodyIndex) or Identifier<Tag> (e.g., GeometryId), right now the default fmt::format output for that value is just the underlying bare integer. The type (e.g., "body" or "geometry") might not always be clear from context, so sometimes the error message text needs to laboriously incorporate the type.
|
throw std::logic_error(fmt::format( |
|
"The given {}Index({}) is out of bounds (must be less than {})", |
|
nice_type, index, next_index())); |
Describe the solution you'd like
Enhance TypeSafeIndex<Tag> and Identifier<Tag> to offer a repr formatter, so that the format string could be something like fmt::format("The given {:r} is out of bounds", index).
Describe alternatives you've considered
N/A
Additional context
N/A
Is your feature request related to a problem? Please describe.
When an error message incorporates a
TypeSafeIndex<Tag>(e.g.,BodyIndex) orIdentifier<Tag>(e.g.,GeometryId), right now the defaultfmt::formatoutput for that value is just the underlying bare integer. The type (e.g., "body" or "geometry") might not always be clear from context, so sometimes the error message text needs to laboriously incorporate the type.drake/multibody/tree/element_collection.cc
Lines 151 to 153 in 63201f5
Describe the solution you'd like
Enhance
TypeSafeIndex<Tag>andIdentifier<Tag>to offer a repr formatter, so that the format string could be something likefmt::format("The given {:r} is out of bounds", index).Describe alternatives you've considered
N/A
Additional context
N/A