Trace.current constructor
Returns the current stack trace.
By default, the first frame of this trace will be the line where
Trace.current is called. If level
is passed, the trace will start that
many frames up instead.
Implementation
factory Trace.current([int level = 0]) {
if (level < 0) {
throw new ArgumentError("Argument [level] must be greater than or equal "
"to 0.");
}
var trace = new Trace.from(StackTrace.current);
return new LazyTrace(() {
// JS includes a frame for the call to StackTrace.current, but the VM
// doesn't, so we skip an extra frame in a JS context.
return new Trace(trace.frames.skip(level + (inJS ? 2 : 1)),
original: trace.original.toString());
});
}