Chain.forTrace constructor

Chain.forTrace(
  1. StackTrace trace
)

Returns the stack chain associated with trace.

The first stack trace in the returned chain will always be trace (converted to a Trace if necessary). If there is no chain associated with trace or if this is called outside of a capture zone, this just returns a single-trace chain containing trace.

If trace is already a Chain, it will be returned as-is.

Implementation

factory Chain.forTrace(StackTrace trace) {
  if (trace is Chain) return trace;
  if (_currentSpec != null) return _currentSpec.chainFor(trace);
  if (trace is Trace) return Chain([trace]);
  return LazyChain(() => Chain.parse(trace.toString()));
}