Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1174)

Unified Diff: pkg/stack_trace/lib/src/trace.dart

Issue 137443002: Validate that Trace.from's argument isn't null. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698