Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception thrown is not being returned in editor #1982

Open
bpringe opened this issue Nov 28, 2022 · 4 comments
Open

Exception thrown is not being returned in editor #1982

bpringe opened this issue Nov 28, 2022 · 4 comments
Labels
bug Something isn't working evaluation nrepl

Comments

@bpringe
Copy link
Member

bpringe commented Nov 28, 2022

With this code:

(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:

-> sent
{
  id: '196',
  op: 'eval',
  session: 'f5d05f33-b88a-4640-82c9-98ed61dc9298',
  code: '(weighted-average [1 2 3] (range))',
  file: '<file-path>/core.clj',
  line: 34,
  column: 3,
  stdout: [Function: stdout],
  stderr: [Function: stderr],
  pprint: true
}

<- received
{
  err: 'Execution error (ExceptionInfo) at <namespace>/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' ]
}
@PEZ
Copy link
Collaborator

PEZ commented Nov 28, 2022

Thanks for reporting!

Do you see any clues in the dev console?

@bpringe
Copy link
Member Author

bpringe commented Nov 28, 2022

Nothing was printed in the dev console when I ran the eval.

@bpringe bpringe added the bug Something isn't working label Nov 29, 2022
@bpringe
Copy link
Member Author

bpringe commented Nov 29, 2022

I went back to Calva version 2.0.219 and the problem is reproducible in that version too. Another thing to note is that soon after the "done" message for the eval that throws the exception, messages stop being "received" from nrepl (at least as far as the logs show). When I try to eval something, or hover over something, the messages sent don't have any responses.

A message or two immediately after the eval of the function call do have responses returned, but after that, no responses.

@bpringe
Copy link
Member Author

bpringe commented Nov 29, 2022

Problem also happens back in 2.0.216. If I just write a function that calls (throw (ex-info ... and call it, Calva shows me the error. It's something specific with the code I posted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working evaluation nrepl
Projects
None yet
Development

No branches or pull requests

2 participants