Skip to content

Conversation

dvdsk
Copy link
Member

@dvdsk dvdsk commented Aug 9, 2025

Thiserror

This reverts PR #633 in which thiserror was removed. At the time there where only two Error types. I expected that number not to increase. Clearly I was wrong as we now we have 6. Therefore this re-introduces thiserror.

Note the original argument against this thiserror by est31 in 2021:

I'm not in favour of adding thiserror, it pulls in a huge set of
dependencies for very little improvement in comfort.

Since then thiserror has become the error handling crate for use in crates (24580 published crates depend on thiserror). The crate most used for error handling in binaries (anyhow) even relies on thiserror. Thiserror is also increadibly stable.

Therefore the chance is really quite slim a rodio user will not already have the right thiserror version somewhere in their dependency tree. Which means the compile time impact is neglible in most cases.

Output to wav

Gets its own type, it was Box<dyn Error> which does not work for wrapping it in anything requiring Box<dyn Error + Send + Sync + 'static>. Unfortunaly making wav_output return a
Box<dyn Error + Send + Sync + 'static> will break usage in functions returning Box<dyn Error> (yeah this suprised me too).

Errors Clone

This also makes all our errors clonable by swapping Box with Arc and wrapping non clone errors in an Arc.

Errors trait check macro

Finally I've added a macro (assert_error_traits) in common to verify an Error type is Send + Sync + Clone + Debug + Display + 'static.

@roderickvd
Copy link
Member

Looks great. I'm in favor.

dvdsk added 2 commits August 14, 2025 01:11
== Thiserror
This reverts PR #633 in which thiserror was removed. At the time there
where only two Error types. I expected that number not to increase.
Clearly I was wrong as we now we have 6. Therefore this re-introduces
thiserror.

Note the original argument against this thiserror by est31 in 2021:

> I'm not in favour of adding thiserror, it pulls in a huge set of
dependencies for very little improvement in comfort.

Since then thiserror has become *the* error handling crate for use in
crates (24580 published crates depend on thiserror). The crate most used
for error handling in binaries (anyhow) even relies on thiserror.
Thiserror is also increadibly stable.

Therefore the chance is really quite slim a rodio user will not already
have the right thiserror version somewhere in their dependency tree.
Which means the compile time impact is neglible in most cases.

== Output to wav
Gets its own type, it was `Box<dyn Error>` which does not work for
wrapping it in anything requiring `Box<dyn Error + Send + Sync +
'static>`. Unfortunaly making wav_output return a
`Box<dyn Error + Send + Sync + 'static>` will break usage in functions
returning `Box<dyn Error>` (yeah this suprised me too).

== Errors Clone
This also makes all our errors clonable by swapping Box with Arc and
wrapping non clone errors in an Arc.

== Errors trait check macro
Finally I've added a macro (`assert_error_traits`) in `common` to
verify an Error type is Send + Sync + Clone + Debug + Display + 'static.
@dvdsk dvdsk merged commit aafc09f into master Aug 13, 2025
9 checks passed
@dvdsk
Copy link
Member Author

dvdsk commented Aug 13, 2025

rebased and merged :)

@dvdsk dvdsk deleted the thiserror branch August 13, 2025 23:37
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.

2 participants