mirror of
https://github.com/esphome/esphome.git
synced 2026-09-19 11:08:38 +00:00
Merge branch 'mapping_debug' into integration
This commit is contained in:
@@ -45,20 +45,16 @@ template<typename K, typename V> class Mapping {
|
||||
} else if constexpr (std::is_same_v<K, std::string>) {
|
||||
esph_log_e(TAG, "Key '%s' not found in mapping", key.c_str());
|
||||
} else if constexpr (std::is_integral_v<K>) {
|
||||
char buf[24]; // enough for int64_t
|
||||
buf_append_printf(buf, sizeof(buf), 0, "%" PRId64, static_cast<int64_t>(key));
|
||||
esph_log_e(TAG, "Key '%s' not found in mapping", buf);
|
||||
} else if constexpr (std::is_floating_point_v<K>) {
|
||||
char buf[24];
|
||||
buf_append_printf(buf, sizeof(buf), 0, "%g", static_cast<double>(key));
|
||||
esph_log_e(TAG, "Key '%s' not found in mapping", buf);
|
||||
} else if constexpr (std::is_enum_v<K>) {
|
||||
char buf[24]; // enough for underlying integral type
|
||||
buf_append_printf(buf, sizeof(buf), 0, "%" PRId64, static_cast<int64_t>(key));
|
||||
char buf[24]; // enough for 64-bit integer
|
||||
if constexpr (std::is_unsigned_v<K>) {
|
||||
buf_append_printf(buf, sizeof(buf), 0, "%" PRIu64, static_cast<uint64_t>(key));
|
||||
} else {
|
||||
buf_append_printf(buf, sizeof(buf), 0, "%" PRId64, static_cast<int64_t>(key));
|
||||
}
|
||||
esph_log_e(TAG, "Key '%s' not found in mapping", buf);
|
||||
} else {
|
||||
// Fallback for custom types - likely unreachable but kept for compatibility
|
||||
esph_log_e(TAG, "Key '%s' not found in mapping", to_string(key).c_str());
|
||||
// All supported key types are handled above - this should never be reached
|
||||
static_assert(sizeof(K) == 0, "Unsupported key type for Mapping error logging");
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user