From: "Suraj N. Kurapati" Date: 2008-03-31T06:46:18+09:00 Subject: Re: C extension - how to print exception like Ruby? Suraj N. Kurapati wrote: > rb_eval_string_protect( // <====== output is not beautiful > "if (e = $!) then STDERR.puts" > "(e.inspect, e.backtrace) end", > &error > ); Here is a more accurate mimicry of Ruby's internal exception printing logic: rb_eval_string_protect("if (e = $!) then STDERR.puts(\"#{e.class}: #{e.message}\", e.backtrace.map {|s| \"\tfrom #{s}\" }) end", &error); Nevertheless, it would be nice if Exception#inspect() produced this output or if the Ruby C API provided a function to dump the details of an exception just like Ruby does internally.