BetterThanTomorrow / BetterThanTomorrow/calva
Exception thrown is not being returned in editor
- Dominant language
- TypeScript
- Stars
- 2.1k
- Forks
- 249
- Avg merge
- 6h 24m
- Merged PRs (30d)
- 9
Description
With this code:
```clojure
(defn weighted-average
[weights values]
(if (and (or (list? weights) (vector? weights))
(or (list? values) (vector? values)))
(if (= (count weights) (count values))
(let [weighted-sum (reduce + (map * weights values))]
(/ weighted-sum (reduce + weights)))
(throw (ex-info "The number of weights must equal the number of values."
{:weights weights
:values values})))
(throw (ex-info "The weights and values must be lists or vectors."
{:weights weights
:values values}))))
```
If I evaluate this from my editor or the output window, the evaluation seems to never return. I cannot evaluate anything else and get a result, either. Interrupting the eval doesn't seem to work.
However, in the nrepl logs, I see the expected exception (at the bottom of the function) is returned after I eval the call to the function. It just never appears in the output window or in the editor.
A friend of mine can eval the call in emacs and see the expected exception without any issue.
nrepl logs:
```text
-> sent
{
id: '196',
op: 'eval',
session: 'f5d05f33-b88a-4640-82c9-98ed61dc9298',
code: '(weighted-average [1 2 3] (range))',
file: '/core.clj',
line: 34,
column: 3,
stdout: [Function: stdout],
stderr: [Function: stderr],
pprint: true
}
<- received
{
err: 'Execution error (ExceptionInfo) at /weighted-average (core.clj:27).\n' +
'The weights and values must be lists or vectors.\n',
id: '196',
session: 'f5d05f33-b88a-4640-82c9-98ed61dc9298'
}
<- received
{
ex: 'class clojure.lang.ExceptionInfo',
id: '196',
'root-ex': 'class clojure.lang.ExceptionInfo',
session: 'f5d05f33-b88a-4640-82c9-98ed61dc9298',
status: [ 'eval-error' ]
}
<- received
{
id: '196',
session: 'f5d05f33-b88a-4640-82c9-98ed61dc9298',
status: [ 'done' ]
}
```
Contributor guide
Research direction
Start by reproducing the evaluation from the editor or output window using the weighted-average example, then compare its handling with the nREPL response sequence showing err, eval-error, and done. Done means the exception appears in the editor or output window, the evaluation finishes, and subsequent evaluations return results; verify this against the nREPL logs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure, typescript
- Domain
- developer-experience, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100