Skip to content

Commit 226440c

Browse files
authored
Merge pull request #25 from ogios/master
hotfix: do not return error when getting IconName and IconPixmap but log a warning to the output
2 parents 9173e21 + fc8de2c commit 226440c

File tree

1 file changed

+38
-18
lines changed

1 file changed

+38
-18
lines changed

src/client.rs

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -440,51 +440,71 @@ impl Client {
440440
}
441441
_ => Err(Into::<Error>::into(e)),
442442
},
443-
}?
443+
}
444444
};
445445
}
446446

447447
let property = match member.as_str() {
448448
"NewAttentionIcon" => Some(AttentionIcon(
449-
get_property!("AttentionIconName")
449+
get_property!("AttentionIconName")?
450450
.as_ref()
451451
.map(OwnedValueExt::to_string)
452452
.transpose()?,
453453
)),
454-
"NewIcon" => Some(Icon {
455-
icon_name: get_property!("IconName")
456-
.as_ref()
457-
.map(OwnedValueExt::to_string)
458-
.transpose()?,
459-
icon_pixmap: get_property!("IconPixmap")
460-
.as_deref()
461-
.map(Value::downcast_ref::<&Array>)
462-
.transpose()?
463-
.map(IconPixmap::from_array)
464-
.transpose()?,
465-
}),
454+
"NewIcon" => {
455+
let icon_name = match get_property!("IconName") {
456+
Ok(name) => name,
457+
Err(e) => {
458+
warn!("Error getting IconName: {e:?}");
459+
None
460+
}
461+
}
462+
.as_ref()
463+
.map(OwnedValueExt::to_string)
464+
.transpose()
465+
.ok()
466+
.flatten();
467+
468+
let icon_pixmap = match get_property!("IconPixmap") {
469+
Ok(pixmap) => pixmap,
470+
Err(e) => {
471+
warn!("Error getting IconPixmap: {e:?}");
472+
None
473+
}
474+
}
475+
.as_deref()
476+
.map(Value::downcast_ref::<&Array>)
477+
.transpose()?
478+
.map(IconPixmap::from_array)
479+
.transpose()?;
480+
481+
Some(Icon {
482+
icon_name,
483+
icon_pixmap,
484+
})
485+
}
466486
"NewOverlayIcon" => Some(OverlayIcon(
467-
get_property!("OverlayIconName")
487+
get_property!("OverlayIconName")?
468488
.as_ref()
469489
.map(OwnedValueExt::to_string)
470490
.transpose()?,
471491
)),
472492
"NewStatus" => Some(Status(
473-
get_property!("Status")
493+
get_property!("Status")?
474494
.as_deref()
475495
.map(Value::downcast_ref::<&str>)
476496
.transpose()?
477497
.map(item::Status::from)
478498
.unwrap_or_default(), // NOTE: i'm assuming status is always set
479499
)),
480500
"NewTitle" => Some(Title(
481-
get_property!("Title")
501+
get_property!("Title")?
482502
.as_ref()
483503
.map(OwnedValueExt::to_string)
484504
.transpose()?,
485505
)),
486506
"NewToolTip" => Some(Tooltip(
487-
get_property!("ToolTip")
507+
get_property!("ToolTip")?
488508
.as_deref()
489509
.map(Value::downcast_ref::<&Structure>)
490510
.transpose()?

0 commit comments

Comments
 (0)