-
Notifications
You must be signed in to change notification settings - Fork 127
Exception printing and querying #192
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 printing and querying #192
Conversation
pixie/stdlib.pxi
Outdated
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.
should this be the var e instead of *e?
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.
yes indeed - nice catch :)
|
BTW, this build failed due to BitBucket being down. Not your fault. |
pixie/vm/stdlib.py
Outdated
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.
I like this, but I'd also like a bit more detail. Can we add a method to each of the ErrorInfo types (found here: https://github.com/pixie-lang/pixie/blob/master/pixie/vm/object.py#L157), that construct a map or something for each frame? As it stands we'd need to parse the strings if we want anything useful out of the trace. So you could probably just clone each __repr__ method and construct a map instead of a string. So polymorphic code info would look something like {:type :polymorphic :name "-count" :type <type int>}
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.
BTW, keep the patches coming, it's great to see this stuff moving forward.
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.
👍 ✨
|
Here is my next pass of exception trace maps: Pixie 0.1 - Interactive REPL
(darwin_x86_64, clang)
:exit-repl or Ctrl-D to quit
----------------------------
user => (/ 0 0)
Error: in <unknown> at 1:1
(/ 0 0)
^
in pixie function
in /Users/cmeier/workspace/misc/pixie/pixie/stdlib.pxi at 511:10
([x y] (-div x y))
^
in internal function _div
RuntimeException: Divide by zero
user => (trace)
({:data "Divide by zero", :type "runtime"} {:type "native", :name "_div"} {:line_number "511", :line " ([x y] (-div x y))", :column_number "10", :type "interpreter", :file "/Users/cmeier/workspace/misc/pixie/pixie/stdlib.pxi"} {:type "pixie", :name ""} {:line_number "1", :line "(/ 0 0)", :column_number "1", :type "interpreter", :file "<unknown>"})
feedback welcome as always |
|
That looks pretty good! ✨ Why did you make (And even more nitpicky: Could you change the names to |
|
Thanks - great feedback. I will make the changes. I am still struggling working with python/rpython, so I lose track of the little stuff sometimes while just trying to get it to compile and build :) |
pixie/stdlib.pxi
Outdated
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.
You can already do this with (print (str e)), then you don't need a separate ex-pr or alternatively implement it as just (print (str e)).
(Sorry that this is so late.)
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.
Cool I will update in the pull request
|
Cool - implemented the changes and learned quite a bit about rpython in the process :) Here is the latest:
user => (/ 0 0)
Error: in <unknown> at 1:1
(/ 0 0)
^
in pixie function
in /Users/cmeier/workspace/misc/pixie/pixie/stdlib.pxi at 511:10
([x y] (-div x y))
^
in internal function _div
RuntimeException: Divide by zero
user => (trace)
({:data "Divide by zero", :type :runtime} {:type :native, :name "_div"} {:line-number 511, :line " ([x y] (-div x y))", :column-number 10, :type :interpreter, :file "/Users/cmeier/workspace/misc/pixie/pixie/stdlib.pxi"} {:type :pixie, :name ""} {:line-number 1, :line "(/ 0 0)", :column-number 1, :type :interpreter, :file "<unknown>"}) |
|
Thanks a lot! ✨ |
Some basic functions for dealing with exceptions.
This adds a way to print and turn stack traces into seqs.
It adds two functions
pstandtracepstworks on either an exception or if no arg is given the last exception thrown as*e. It will simply print the stack trace.tracealso works on either an exception or if none is given, the last bound to*e. It turns the trace into a seq, which someone can do further processing and inspection on.seqwas also extended to Runtime Exceptions.@halgari Let me know if this is what you were thinking of..