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

Unified Diff: pkg/front_end/lib/compiler_options.dart

Issue 2568583002: Create a default error handler to avoid the need for null checks. (Closed)
Patch Set: Created 4 years 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/front_end/lib/compiler_options.dart
diff --git a/pkg/front_end/lib/compiler_options.dart b/pkg/front_end/lib/compiler_options.dart
index ac75dd112906137788f7eb2640441b359c901a9e..05be3eaaff8e2c8eeaf33042d23cadf3c5c2f303 100644
--- a/pkg/front_end/lib/compiler_options.dart
+++ b/pkg/front_end/lib/compiler_options.dart
@@ -8,6 +8,9 @@ import 'compilation_error.dart';
import 'file_system.dart';
import 'physical_file_system.dart';
+/// Default error handler used by [CompielerOptions.onError].
+void defaultErrorHandler(CompilationError error) => throw error;
+
/// Callback used to report errors encountered during compilation.
typedef void ErrorHandler(CompilationError error);
@@ -25,9 +28,9 @@ class CompilerOptions {
/// Callback to which compilation errors should be delivered.
///
- /// If `null`, the first error will be reported by throwing an exception of
+ /// By default, the first error will be reported by throwing an exception of
/// type [CompilationError].
- ErrorHandler onError;
+ ErrorHandler onError = defaultErrorHandler;
/// Path to the ".packages" file.
///
« 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