[HN Gopher] Implementing Rust newtype for errors in axum
___________________________________________________________________
Implementing Rust newtype for errors in axum
Author : ruptwelve
Score : 12 points
Date : 2025-11-17 19:22 UTC (3 hours ago)
(HTM) web link (rup12.net)
(TXT) w3m dump (rup12.net)
| hobs wrote:
| Like the post, but the backticks on all sorts of things is very
| distracting - am I missing some value here?
| ruptwelve wrote:
| I'll chalk that up to my Astro theme. It's supposed to be just
| `Something` and the backticks should have not been visible!
| Sorry!
| goddtriffin wrote:
| Great post. I do the same thing for all of my Rust web servers
| too. I don't use anyhow though, prefer rolling everything myself
| - which as you call out is a pain after a while.
| ruptwelve wrote:
| `Anyhow` is a great thing to get you started. But ultimately
| you wanna use some bespoke errors, and just roll your own!
| vsgherzi wrote:
| would you get backtraces with this implementation? I've been
| increasingly frustrated with axum. It hits my custom error where
| I print something like "sqlx database failed" but when there's
| lots of traffic it's hard to determine which of the hundreds of
| queries actually failed. What I really want is the top part of a
| backtrace or at least a line number. I know anyhow gives bts but
| will it actually be useful when used like this?
|
| Anyone else have ideas on how to solve this?
| dlahoda wrote:
| i do not see problems with axum.
|
| we wrote some macro(with muncher) which allows strongly typed
| and yet dry per method error, error split of public part vs
| internal log only(with backtrace crate trace capture), full
| openapi support(via schemars) and we do not use anyhow.
|
| whole article is rot and bad advice.
| vsgherzi wrote:
| mind sharing a link?
___________________________________________________________________
(page generated 2025-11-17 23:01 UTC)