Create a default error handler to avoid the need for null checks.

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2568583002 .
This commit is contained in:
Paul Berry 2016-12-12 10:54:38 -08:00
parent f43db9ccfa
commit d70184abd8

View file

@ -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.
///