Skip to content

Conversation

@chet
Copy link
Contributor

@chet chet commented Nov 22, 2025

#809 had been opened inquiring about implementing std::error::Error for cursive::theme::Error so they could do something like this:

fn load_theme(siv: &mut CursiveRunnable, path: PathBuf) -> anyhow::Result<()> {
    siv.load_theme_file(path)?;
    Ok(())
}

Instead of having to do this:

fn load_theme(siv: &mut CursiveRunnable, path: PathBuf) -> anyhow::Result<()> {
    match siv.load_theme_file(path) {
        Ok(_) => Ok(()),
        Err(e) => match e {
            cursive::theme::Error::Io(e) => Err(e.into()),
            cursive::theme::Error::Parse(e) => Err(e.into()),
        }
    }
}

It seemed like low hanging fruit, so I figured I'd offer up a PR. Included some tests for the different Error::Io, Error::Parse and ? cases.

Thank you for considering this change!

…:Error

gyscos#809 had been opened inquiring about implementing `std::error::Error` for `cursive::theme::Error` so they could do something like this:

```
fn load_theme(siv: &mut CursiveRunnable, path: PathBuf) -> anyhow::Result<()> {
    siv.load_theme_file(path)?;
    Ok(())
}
```

Instead of having to do this:

```
fn load_theme(siv: &mut CursiveRunnable, path: PathBuf) -> anyhow::Result<()> {
    match siv.load_theme_file(path) {
        Ok(_) => Ok(()),
        Err(e) => match e {
            cursive::theme::Error::Io(e) => Err(e.into()),
            cursive::theme::Error::Parse(e) => Err(e.into()),
        }
    }
}
```

It seemed like low hanging fruit, so I figured I'd offer up a PR. Included some tests for the different `Error::Io`, `Error::Parse` and `?` cases.

Thank you for considering this change!
@chet
Copy link
Contributor Author

chet commented Nov 22, 2025

cc @septante

@septante
Copy link

I ended up switching to ratatui because I needed support for rendering images, but this looks like what I was asking for. Thank you!

@chet
Copy link
Contributor Author

chet commented Nov 23, 2025

Ahh nice @septante! And you're welcome! Better late than never, haha!

@gyscos
Copy link
Owner

gyscos commented Nov 27, 2025

Thanks for the PR!

@chet
Copy link
Contributor Author

chet commented Nov 27, 2025

@gyscos Of course! I'll try to look through the Issues list and see if I can grab a few more of them over the next few weeks.

@gyscos gyscos merged commit c74fecb into gyscos:main Nov 27, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants