| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -44,6 +44,7 @@ | |
| import org.jruby.runtime.JavaInternalBlockBody; | ||
| import org.jruby.runtime.Signature; | ||
| import org.jruby.runtime.ThreadContext; | ||
| import org.jruby.runtime.backtrace.RubyStackTraceElement; | ||
| import org.jruby.runtime.backtrace.TraceType; | ||
| import org.jruby.runtime.builtin.IRubyObject; | ||
| import org.jruby.util.RubyStringBuilder; | ||
| Expand Down Expand Up | @@ -223,9 +224,8 @@ public static class Throwable { | |
| public static IRubyObject backtrace(final ThreadContext context, final IRubyObject self) { | ||
| final Ruby runtime = context.runtime; | ||
| java.lang.Throwable throwable = unwrapIfJavaObject(self); | ||
| // TODO instead this should get aligned with NativeException !?! | ||
| StackTraceElement[] stackTrace = throwable.getStackTrace(); | ||
| if ( stackTrace == null ) return context.nil; // never actually happens | ||
| if ( stackTrace == null ) return context.nil; | ||
| final int len = stackTrace.length; | ||
| if ( len == 0 ) return RubyArray.newEmptyArray(runtime); | ||
| IRubyObject[] backtrace = new IRubyObject[len]; | ||
| Expand All | @@ -235,6 +235,20 @@ public static IRubyObject backtrace(final ThreadContext context, final IRubyObje | |
| return RubyArray.newArrayMayCopy(runtime, backtrace); | ||
| } | ||
|
|
||
| @JRubyMethod | ||
| public static IRubyObject backtrace_locations(final ThreadContext context, final IRubyObject self) { | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis and backtrace are very similar. Maybe share the common parts and just construct the elements differently.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualityyeah the preamble, but even if we dry out the loop mapping with a function you still need to return a different array.
Sorry, something went wrong.
All reactions
|
||
| java.lang.Throwable throwable = unwrapIfJavaObject(self); | ||
| StackTraceElement[] stackTrace = throwable.getStackTrace(); | ||
| if ( stackTrace == null ) return context.nil; | ||
| final int len = stackTrace.length; | ||
| if ( len == 0 ) return RubyArray.newEmptyArray(context.runtime); | ||
| RubyStackTraceElement[] rubyStackTrace = new RubyStackTraceElement[len]; | ||
| for ( int i = 0; i < len; i++ ) { | ||
| rubyStackTrace[i] = new RubyStackTraceElement(stackTrace[i]); | ||
| } | ||
| return RubyThread.Location.newLocationArray(context.runtime, rubyStackTrace); | ||
| } | ||
|
|
||
| @Deprecated(since = "10.0.0.0") | ||
| public static IRubyObject set_backtrace(final IRubyObject self, final IRubyObject backtrace) { | ||
| return set_backtrace(((RubyBasicObject) self).getCurrentContext(), self, backtrace); | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWould a new overload of newLocation make sense here?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualitynot sure, literally would be the same as doing new Location() directly.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.