You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to get the stacktrace from an nREPL session using clj-stacktrace's parse-exception.
I would get it back as a String, which I could then apply read-string to and either use as I need, or pass on to pst-str.
However, when the parsed structure is converted to a String and then back again, the value for the top level :class goes from Class to Symbol, which then causes an exception.
This works: (try (/ 0) (catch Exception e (-> e parse-exception pst-str)))
This does not work: (try (/ 0) (catch Exception e (-> e parse-exception str read-string pst-str)))
It gives the exception:
ClassCastException clojure.lang.Symbol cannot be cast to java.lang.Class clj-stacktrace.repl/pst-class-on (repl.clj:59)
I can of course apply this work-around (I convert the symbol to a class):
(try (/ 0) (catch Exception e (-> e parse-exception str read-string (update-in [:class] class) pst-str)))
Suggested fix - alternative 1:
Remove the type-hint in line 58, and to a type-test and conversion or similar before building the pst-line in lin 59.
Suggested fix - alternative 2:
Have parse-exception return a String-value for :class - in the same way as the :class value is a String in the stacktrace-elements.
I would prefer alternative 2, as it would be more consistent in general. On the downside, it might break something for other users, assuming the expect a Class, but now get a String.
Either way, would you like me to submit a pull-request for one of the fix-alternatives?
If so, which one?
The text was updated successfully, but these errors were encountered:
I would like to get the stacktrace from an nREPL session using clj-stacktrace's
parse-exception
.I would get it back as a String, which I could then apply
read-string
to and either use as I need, or pass on topst-str
.However, when the parsed structure is converted to a String and then back again, the value for the top level
:class
goes from Class to Symbol, which then causes an exception.This works:
(try (/ 0) (catch Exception e (-> e parse-exception pst-str)))
This does not work:
(try (/ 0) (catch Exception e (-> e parse-exception str read-string pst-str)))
It gives the exception:
I can of course apply this work-around (I convert the symbol to a class):
Suggested fix - alternative 1:
Remove the type-hint in line 58, and to a type-test and conversion or similar before building the pst-line in lin 59.
Suggested fix - alternative 2:
Have
parse-exception
return a String-value for:class
- in the same way as the:class
value is a String in the stacktrace-elements.I would prefer alternative 2, as it would be more consistent in general. On the downside, it might break something for other users, assuming the expect a Class, but now get a String.
Either way, would you like me to submit a pull-request for one of the fix-alternatives?
If so, which one?
The text was updated successfully, but these errors were encountered: