ITADN

Add option to remove throws keyword from RouterMethods handlers

#785OpenCyberbeni 创建于 2026-02-18
C
Cyberbenicommented
Reading [this](https://forums.swift.org/t/pitch-remove-discardableresult-from-throwing-task-initializers/84721) thread reminded me of an occasion when I accidentally left a top level throw inside a `get` handler in one of my projects. I would prefer if this wasn't allowed, so I am forced to make a conscious decision whether it's a 400 or a 500 error (or a rare case when it's something else) instead of automatically converting the error to a 500(?) response for me. The actual implementation would probably be `#if TRAIT` around typalias `any Error`/`Never` and then using typed throws with that type. Hopefully the final release of 6.3 keeps the fix, so non-default traits become easily usable for everyone: https://github.com/hummingbird-project/hummingbird/issues/769#issuecomment-3822869244
3 条评论