Our great sponsors
-
wherr
Enhance Rust errors with file and line details using the `#[wherr]` macro for clearer debugging.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
https://github.com/joelonsql/wherr/commit/c5906a257fc9768ad0...
I couldn't figure out how to make it work though, since with these changes, now nested functions using the #[wherr] macro won't work due to "doesn't have a size known at compile-time".
The other idea of just using #[track_caller] also seems promising, and will be considered for a future major version.
But I still think it's interesting if the macro variant can be improved, to avoid having to do dynamic casts, hence this new branch.
We opted for a more manual approach, we have a ctx!() macro[1] we use for wrapping errors we want to enrich thay we use like this[2]: ctx!(some_fallible_fund(foo))?
I wodner if anyone is doing anything better? The nice thing is that we have relevant fields in our error type, so we get a full backtrace out if it.
1: https://github.com/svix/svix-webhooks/blob/main/server/svix-...
2: https://github.com/svix/svix-webhooks/blob/main/server/svix-...
We can also optimize this more (e.g. a simple optimization to be two words instead of three: https://play.rust-lang.org/?version=stable&mode=debug&editio.... Also allows opting `Send` and `Sync` out or using non-`'static` lifetimes), but this works as a baseline. The only disadvantage is that if called in a function with `#[track_caller]` this will report the location of the caller... But this is something I can live with.