Coder Social home page Coder Social logo

mruby_better_backtrace_snipet's Introduction

mruby_better_backtrace_snipet

mruby better backtrace snipet

When this code run on mruby,

def g
  raise "test"
end

def f
  begin
    g
  rescue => e
    raise e
  end
end

begin
  f
rescue => e
  puts "e.backtrace"
  puts "#{e.backtrace.map{|v| "  " + v}.join("\n")}"
end

you get following.

e.backtrace
  exception_default.rb:18

if you add code from exception_better_backtrace_snipet.rb

you get following

e.backtrace
  exception_better_backtrace.rb:37:in Object.g
  exception_better_backtrace.rb:42:in Object.f
  exception_better_backtrace.rb:49

I prfefer this.

run test

# cd test
# ruby setup.rb

... build ruby ...

mruby exception backtrace
e.backtrace
  exception_default.rb:18

ruby exception backtrace
e.backtrace
  exception_default.rb:3:in `g'
  exception_default.rb:8:in `f'
  exception_default.rb:15:in `<main>'

mruby better exception backtrace
e.backtrace
  exception_better_backtrace.rb:37:in Object.g
  exception_better_backtrace.rb:42:in Object.f
  exception_better_backtrace.rb:49

ruby better exception backtrace
e.backtrace
  exception_better_backtrace.rb:37:in `raise'
  exception_better_backtrace.rb:37:in `g'
  exception_better_backtrace.rb:42:in `f'
  exception_better_backtrace.rb:49:in `<main>'

mruby fiber exception backtrace
e.backtrace
  exception_fiber.rb:19

ruby fiber exception backtrace
e.backtrace
  exception_fiber.rb:6:in `block in f'

mruby fiber better exception backtrace
e.backtrace
  exception_fiber_better_backtrace.rb:40

ruby fiber better exception backtrace
e.backtrace
  exception_fiber_better_backtrace.rb:40:in `raise'
  exception_fiber_better_backtrace.rb:40:in `block in f'

mruby_better_backtrace_snipet's People

Contributors

dycoon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.