-
Notifications
You must be signed in to change notification settings - Fork 15
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
Include line info for steps that raise exceptions #77
Conversation
src/state_flow/core.clj
Outdated
`(m/do-let | ||
(push-meta ~description ~flow-meta) | ||
[ret# (m/do-let ~@flows')] | ||
~@but-last-flows | ||
~(push-abbr-meta last-flow) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding both the outer flow desc and the actual call sight info can be very useful. For example
(state-flow/run!
(state-flow/flow "buggy flow"
(change-state-buggy)))
correctly shows
Syntax error (ExceptionInfo) compiling at (state_flow/scratch.clj:12:1).
Flow "buggy flow (line 13) -> `(change-stat...)` (line 18)" failed with exception
You can also do It seems like a better trade off than a complicated solution just to provide line number tracking for primitive steps. |
This is a more contrived issue. I came across an interesting article about it, though, and might be a good direction to follow: https://pepeiborra.wordpress.com/2009/11/01/monadic-stack-traces-that-make-a-lot-of-sense/ I've only skimmed through the article, but the proposed solution is basically implementing an error monad that carries the stack trace |
cb5e314
to
640e2ee
Compare
I've cleaned the implementation and it should be ready to review again |
src/state_flow/core.clj
Outdated
(or (= 'flow (first expr)) | ||
(= `flow (first expr))))) | ||
|
||
(defn annote-with-line-meta [flows] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(defn annote-with-line-meta [flows] | |
(defn annotate-with-line-meta [flows] |
|
||
(testing "after nested flows complete" | ||
(testing "within nested flows " | ||
(is (re-matches #"level 1 \(core_test.clj:\d+\)" | ||
(is (re-matches #"level 1 \(core_test.clj:\d+\) -> \(state-flow\/current-description\) \(line \d+\)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I run this I get
=> "level 1 (core_test.clj:2) -> (state-flow/current-description) (line 4)"
Where line 4
is coming from?
I couldn't find any test when a flow is throwing an exception and the line is included. I guess we are testing Shouldn't we have a test covering the case where an exception is raised and we have line information? |
Thanks for the suggestion @gabrielgiussi, updated with a test |
An attempt to help address #74
Given a flow that raises an exception, like:
the result used to be like the following, which doesn't help pinpoint that
(change-state-buggy)
is the offending step:With the changes in this PR:
Note:
we don't have line metadata info for variable references, so
results in