Skip to content

Commit 86b9a92

Browse files
authored
Add type_name to panic error messages in WidgetPod (#2380)
1 parent 0417723 commit 86b9a92

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ You can find its changes [documented below](#083---2023-02-28).
99

1010
### Added
1111

12+
- Type name is now included in panic error messages in `WidgetPod`. ([#2380] by [@matthewgapp])
13+
1214
### Changed
1315

1416
### Deprecated
@@ -787,6 +789,7 @@ Last release without a changelog :(
787789
[@newcomb-luke]: https://github.com/newcomb-luke
788790
[@AtomicGamer9523]: https://github.com/AtomicGamer9523
789791
[@Insprill]: https://github.com/Insprill
792+
[@matthewgapp]: https://github.com/matthewgapp
790793

791794
[#599]: https://github.com/linebender/druid/pull/599
792795
[#611]: https://github.com/linebender/druid/pull/611
@@ -1233,6 +1236,7 @@ Last release without a changelog :(
12331236
[#2356]: https://github.com/linebender/druid/pull/2356
12341237
[#2375]: https://github.com/linebender/druid/pull/2375
12351238
[#2378]: https://github.com/linebender/druid/pull/2378
1239+
[#2380]: https://github.com/linebender/druid/pull/2380
12361240

12371241
[Unreleased]: https://github.com/linebender/druid/compare/v0.8.3...master
12381242
[0.8.3]: https://github.com/linebender/druid/compare/v0.8.2...v0.8.3

druid/src/core.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ impl<T: Data, W: Widget<T>> WidgetPod<T, W> {
475475

476476
if !self.is_initialized() {
477477
debug_panic!(
478-
"{:?}: paint method called before receiving WidgetAdded.",
478+
"{:?} with widget id {:?}: paint method called before receiving WidgetAdded.",
479+
self.inner.type_name(),
479480
ctx.widget_id()
480481
);
481482
return;
@@ -549,7 +550,8 @@ impl<T: Data, W: Widget<T>> WidgetPod<T, W> {
549550
) -> Size {
550551
if !self.is_initialized() {
551552
debug_panic!(
552-
"{:?}: layout method called before receiving WidgetAdded.",
553+
"{:?} with widget id {:?}: layout method called before receiving WidgetAdded.",
554+
self.inner.type_name(),
553555
ctx.widget_id()
554556
);
555557
return Size::ZERO;
@@ -608,7 +610,8 @@ impl<T: Data, W: Widget<T>> WidgetPod<T, W> {
608610
pub fn event(&mut self, ctx: &mut EventCtx, event: &Event, data: &mut T, env: &Env) {
609611
if !self.is_initialized() {
610612
debug_panic!(
611-
"{:?}: event method called before receiving WidgetAdded.",
613+
"{:?} with widget id {:?}: event method called before receiving WidgetAdded.",
614+
self.inner.type_name(),
612615
ctx.widget_id()
613616
);
614617
return;
@@ -617,8 +620,9 @@ impl<T: Data, W: Widget<T>> WidgetPod<T, W> {
617620
// log if we seem not to be laid out when we should be
618621
if self.state.is_expecting_set_origin_call && !event.should_propagate_to_hidden() {
619622
warn!(
620-
"{:?} received an event ({:?}) without having been laid out. \
623+
"{:?} with widget id {:?} received an event ({:?}) without having been laid out. \
621624
This likely indicates a missed call to set_origin.",
625+
self.inner.type_name(),
622626
ctx.widget_id(),
623627
event,
624628
);
@@ -1015,7 +1019,8 @@ impl<T: Data, W: Widget<T>> WidgetPod<T, W> {
10151019
}
10161020
_ if !self.is_initialized() => {
10171021
debug_panic!(
1018-
"{:?}: received LifeCycle::{:?} before WidgetAdded.",
1022+
"{:?} with widget id {:?}: received LifeCycle::{:?} before WidgetAdded.",
1023+
self.inner.type_name(),
10191024
self.id(),
10201025
event
10211026
);
@@ -1149,7 +1154,8 @@ impl<T: Data, W: Widget<T>> WidgetPod<T, W> {
11491154
(Some(_), None) => self.env = Some(env.clone()),
11501155
(None, _) => {
11511156
debug_panic!(
1152-
"{:?} is receiving an update without having first received WidgetAdded.",
1157+
"{:?} with widget id {:?} is receiving an update without having first received WidgetAdded.",
1158+
self.inner.type_name(),
11531159
self.id()
11541160
);
11551161
return;

0 commit comments

Comments
 (0)