metosin / metosin/ring-http-response
Binary arity for `throw!` fn
- Dominant language
- Clojure
- Stars
- 156
- Forks
- 24
- PR merge metrics
- No merged PRs in 30d
Description
Hi guys! Just a quick question. Why there's no binary arity for `throw!` fn?
```clojure
(defn throw!
"Throwns an exception with ex-info:
{:type :ring.util.http-response/response
:response response}"
([response]
{:pre [(map? response)]}
(throw (ex-info (str "HTTP "(:status response)) {:type ::response :response response})))
([response ex] ; <~ this one is missing
{:pre [(map? response)]}
(throw (ex-info (str "HTTP "(:status response)) {:type ::response :response response} ex))))
```
If it was there it'd be possible to pass the original exception (cause) through to the reitit's catch-all exception middleware/interceptor and, for instance, log it in a centralized manner without losing the trace. But now this information is lost.
Probably there's a reason why it's never been implemented. Is it a bad practice? Am I missing something? Thanks in advance!
Contributor guide
Research direction
Locate the throw! definition in the ring-http-response source and read how its existing arity constructs the exception. Check the surrounding tests or exception-handling behavior, then add and verify the binary-arity behavior so an original exception can be retained as the cause for downstream middleware.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100