Validate that Trace.from's argument isn't null.

R=rnystrom@google.com
BUG=16071

Review URL: https://codereview.chromium.org//137443002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/stack_trace@31762 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/pkgs/stack_trace/lib/src/trace.dart b/pkgs/stack_trace/lib/src/trace.dart
index 21e8afc..c1d751f 100644
--- a/pkgs/stack_trace/lib/src/trace.dart
+++ b/pkgs/stack_trace/lib/src/trace.dart
@@ -92,6 +92,13 @@
   /// 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()));