~whynothugo/shotman

3e98c97025748c889aeeb37282d20bf50f2b9307 — Hugo Osvaldo Barrera 3 months ago 3a39ea9
Minor clean-up in error handling
1 files changed, 8 insertions(+), 6 deletions(-)

M src/main.rs
M src/main.rs => src/main.rs +8 -6
@@ 106,13 106,13 @@ fn main() -> anyhow::Result<()> {
        .expect("target must be set unless --print-dir was specified")
    {
        RequestedTarget::Window => {
            let output_rect = get_focused_output_rect().expect("can get the active output rect");
            let output_rect =
                get_focused_output_rect().context("error getting region for current output")?;
            log::debug!("Output focused rect {}", output_rect);

            let region =
                get_active_window_geom().expect("can get current window geometry via swaymsg");
            let region = get_active_window_geom()
                .context("error getting current window geometry via swaymsg")?;
            log::debug!("Window matches region: {}", region);
            // TODO: bail here if region has size zero.

            DesiredTarget::Region {
                x: i32::from(region.x - output_rect.x),


@@ 123,10 123,12 @@ fn main() -> anyhow::Result<()> {
        }
        RequestedTarget::Output => DesiredTarget::Output,
        RequestedTarget::Region => {
            let region = pick_a_region().expect("can pick a region using slurp");
            let region = pick_a_region().context("error picking a region with slurp")?;

            log::debug!("Manually selected region: {}", region);
            // TODO: bail here if region has size zero.
            if region.width == 0 || region.height == 0 {
                bail!("Empty region selected; nothing to capture");
            }

            DesiredTarget::Region {
                x: i32::from(region.x),