Index: pkg/stack_trace/lib/src/trace.dart |
diff --git a/pkg/stack_trace/lib/src/trace.dart b/pkg/stack_trace/lib/src/trace.dart |
index 21e8afcfced678ad0314ac7eb034f4fea2761f29..c1d751fdd3156eb4150644a391ca6f318b0be48c 100644 |
--- a/pkg/stack_trace/lib/src/trace.dart |
+++ b/pkg/stack_trace/lib/src/trace.dart |
@@ -92,6 +92,13 @@ class Trace implements StackTrace { |
/// If [trace] is a native [StackTrace], its data will be parsed out; if it's |
/// a [Trace], it will be returned as-is. |
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())); |