titan-lang / titan

The Titan programming language
http://titan-lang.org
MIT License
406 stars 13 forks source link

add basic error handler function to validate approach #257

Closed mascarenhas closed 5 years ago

mascarenhas commented 5 years ago

An experiment towards integrating Lua's error handling into Titan that makes errors thrown while executing Titan code throw an object that combines an error object with a stack trace that has both Titan and Lua functions.

The stack trace information for Titan functions has to be obtained through the C mechanisms (either the backtrace function or libbacktrace or libunwind), Titan functions have to be identified and demangled, and the Lua/Titan transitions identified and merged with the Lua stacktrace available through the Callinfo stack.

hishamhm commented 5 years ago

Nice! I think we could add some tiny test for this (run a failing program catching stderr and seeing we got something resembling a backtrace in there?) and merge this initial version as is, then build on top of this in other PRs.

hishamhm commented 5 years ago

(Funny this came along today, I was revisiting my endless "FFI refactor" branch during a flight just yesterday!)

codecov-io commented 5 years ago

Codecov Report

Merging #257 into master will increase coverage by 0.1%. The diff coverage is 96.77%.

Impacted Files Coverage Δ
titan-compiler/util.lua 69.64% <100%> (+0.55%) :arrow_up:
titan-compiler/driver.lua 80% <100%> (+0.76%) :arrow_up:
titan-compiler/coder.lua 94.11% <95.83%> (+0.07%) :arrow_up:
titan-compiler/foreigntypes.lua 96% <0%> (+1%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update cc0647a...d1d858a. Read the comment docs.