Trace.from constructor
Returns a new stack trace containing the same data as trace
.
If trace
is a native StackTrace, its data will be parsed out; if it's
a Trace, it will be returned as-is.
Implementation
factory Trace.from(StackTrace trace) {
// Normally explicitly validating null arguments is bad Dart style, but here
// the natural failure will only occur when the LazyTrace is materialized,
// and we want to provide an error that's more local to the actual problem.
if (trace == null) {
throw new ArgumentError("Cannot create a Trace from null.");
}
if (trace is Trace) return trace;
if (trace is Chain) return trace.toTrace();
return new LazyTrace(() => new Trace.parse(trace.toString()));
}