[Ironruby-core] hosting: howto get the nice ruby backtrace on exception thrown from ruby?
meinrad.recheis at gmail.com
Wed Feb 18 04:24:47 EST 2009
I've given it some thought. I would like to avoid wrapping the code in
"begin - rescue" and instead catch the exception in c#. Then just send the
ruby methods "message" and "backtrace" to the Ruby-exception-object from C#.
How would that be done?
Any other hints?-- Henon
On Tue, Feb 17, 2009 at 11:36 PM, Meinrad Recheis <meinrad.recheis at gmail.com
> I am now currently using this ugly hack to get a reasonable (let's say user
> friendly) exception backtrace from an error in executed code:
> public object Execute(string code, ScriptScope scope)
> code = @"begin
> rescue Exception
> self.__backtrace__ = $!.backtrace
> object result = null;
> LogManager.GetLogger("Ruby").Debug("\r\n" + code);
> result = m_engine.Execute(code, scope);
> catch (Exception e)
> var backtrace =
> string msg = scope.GetVariable<string>("__message__")
> +"\r\n" + string.Join("\r\n", backtrace.Select(s =>
> return result;
> Even though it seems to work well I am absolutely not satisfied with it. Is
> there a better way to do this?
> -- henon
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironruby-core