Package org.jruby.runtime.backtrace

Examples of org.jruby.runtime.backtrace.RubyStackTraceElement


        }
    }

    private static void printExceptionSummary(ThreadContext context, Ruby runtime, RubyException rEx) {
        RubyStackTraceElement[] elements = rEx.getBacktraceElements();
        RubyStackTraceElement firstElement = elements[0];
        String msg = String.format("Exception `%s' at %s:%s - %s\n",
                rEx.getMetaClass(),
                firstElement.getFileName(), firstElement.getLineNumber(),
                runtime.is1_9() ? TypeConverter.convertToType(rEx, runtime.getString(), "to_s") : rEx.convertToString().toString());

        runtime.getErrorStream().print(msg);
    }
View Full Code Here


    public static RubyStackTraceElement[] gatherRawBacktrace(Ruby runtime, StackTraceElement[] stackTrace) {
        List trace = new ArrayList(stackTrace.length);
       
        for (int i = 0; i < stackTrace.length; i++) {
            StackTraceElement element = stackTrace[i];
            trace.add(new RubyStackTraceElement(element));
        }

        RubyStackTraceElement[] rubyStackTrace = new RubyStackTraceElement[trace.size()];
        return (RubyStackTraceElement[])trace.toArray(rubyStackTrace);
    }
View Full Code Here

                assert frames.size() == scopes.size() : "Frames don't match scopes :S";
                for (int i = 0; i < frames.size(); i++) {
                    Frame frame = frames.get(i);
                    IRubyObject s = selfs.get(i);
                    DynamicScope scope = scopes.get(i);
                    RubyStackTraceElement stackElement = trace[i];
                    StaticScope sScope = scope.getStaticScope();
                    Map<String, Object> var = new HashMap<>();
                    String[] names = sScope.getVariables();
                    IRubyObject[] values = scope.getValues();
                    assert names.length == values.length : "Scope name and value length mismatch";
                    for (int j = 0; j < names.length; j++)
                        var.put(names[j], values[j]);
                    DebugFrame created = info.pushFrame(stackElement.getClassName() + "." + stackElement.getMethodName(),
                            stackElement.getFileName(), stackElement.getLineNumber(), s, var);
                    created.self.setName("self");
                }

                // Restore scopes and frames
                while (!scopes.isEmpty()) {
View Full Code Here

        }
    }

    private static void printExceptionSummary(ThreadContext context, Ruby runtime, RubyException rEx) {
        RubyStackTraceElement[] elements = rEx.getBacktraceElements();
        RubyStackTraceElement firstElement = elements.length > 0 ? elements[0] : new RubyStackTraceElement("", "", "(empty)", 0, false);
        String msg = String.format("Exception `%s' at %s:%s - %s\n",
                rEx.getMetaClass(),
                firstElement.getFileName(), firstElement.getLineNumber(),
                runtime.is1_9() ? TypeConverter.convertToType(rEx, runtime.getString(), "to_s") : rEx.convertToString().toString());

        runtime.getErrorStream().print(msg);
    }
View Full Code Here

    public static RubyStackTraceElement[] gatherRawBacktrace(Ruby runtime, StackTraceElement[] stackTrace) {
        List trace = new ArrayList(stackTrace.length);
       
        for (int i = 0; i < stackTrace.length; i++) {
            StackTraceElement element = stackTrace[i];
            trace.add(new RubyStackTraceElement(element));
        }

        RubyStackTraceElement[] rubyStackTrace = new RubyStackTraceElement[trace.size()];
        return (RubyStackTraceElement[])trace.toArray(rubyStackTrace);
    }
View Full Code Here

    public static RubyStackTraceElement[] gatherRawBacktrace(Ruby runtime, StackTraceElement[] stackTrace) {
        List trace = new ArrayList(stackTrace.length);
       
        for (int i = 0; i < stackTrace.length; i++) {
            StackTraceElement element = stackTrace[i];
            trace.add(new RubyStackTraceElement(element));
        }

        RubyStackTraceElement[] rubyStackTrace = new RubyStackTraceElement[trace.size()];
        return (RubyStackTraceElement[])trace.toArray(rubyStackTrace);
    }
View Full Code Here

        }
    }

    private static void printExceptionSummary(ThreadContext context, Ruby runtime, RubyException rEx) {
        RubyStackTraceElement[] elements = rEx.getBacktraceElements();
        RubyStackTraceElement firstElement = elements.length > 0 ? elements[0] : new RubyStackTraceElement("", "", "(empty)", 0, false);
        String msg = String.format("Exception `%s' at %s:%s - %s\n",
                rEx.getMetaClass(),
                firstElement.getFileName(), firstElement.getLineNumber(),
                TypeConverter.convertToType(rEx, runtime.getString(), "to_s"));

        runtime.getErrorStream().print(msg);
    }
View Full Code Here

        // RubyStackTraceElement[] trace = context.gatherCallerBacktrace(level);

        final RubyArray backtrace = runtime.newArray(trace.length);
        final StringBuilder line = new StringBuilder(32);
        for (int i = 0; i < trace.length; i++) {
            RubyStackTraceElement element = trace[i];
            line.setLength(0);
            line.append(element.getFileName()).append(':').
                 append(element.getLineNumber()).append(":in `").
                 append(element.getMethodName()).append('\'');
            backtrace.append( RubyString.newString(runtime, line.toString() ) );
        }
        return backtrace;
    }
View Full Code Here

TOP

Related Classes of org.jruby.runtime.backtrace.RubyStackTraceElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.