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

Side by Side Diff: sdk/lib/async/async_error.dart

Issue 2762953003: More minor type improvements in dart:async. (Closed)
Patch Set: More fixes. Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | sdk/lib/async/broadcast_stream_controller.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.async; 5 part of dart.async;
6 6
7 _invokeErrorHandler( 7 _invokeErrorHandler(
8 Function errorHandler, Object error, StackTrace stackTrace) { 8 Function errorHandler, Object error, StackTrace stackTrace) {
9 if (errorHandler is ZoneBinaryCallback) { 9 if (errorHandler is ZoneBinaryCallback) {
10 return errorHandler(error, stackTrace); 10 return errorHandler(error, stackTrace);
11 } else { 11 } else {
12 ZoneUnaryCallback unaryErrorHandler = errorHandler; 12 ZoneUnaryCallback unaryErrorHandler = errorHandler;
13 return unaryErrorHandler(error); 13 return unaryErrorHandler(error);
14 } 14 }
15 } 15 }
16 16
17 Function _registerErrorHandler<R>(Function errorHandler, Zone zone) { 17 Function _registerErrorHandler<R>(Function errorHandler, Zone zone) {
18 if (errorHandler is ZoneBinaryCallback) { 18 if (errorHandler is ZoneBinaryCallback) {
19 return zone.registerBinaryCallback<R, dynamic, StackTrace>( 19 return zone.registerBinaryCallback<R, Object, StackTrace>(
20 errorHandler as dynamic/*=ZoneBinaryCallback<R, dynamic, StackTrace>*/); 20 errorHandler as dynamic/*=ZoneBinaryCallback<R, Object, StackTrace>*/);
21 } else { 21 } else {
22 return zone.registerUnaryCallback<R, dynamic>( 22 return zone.registerUnaryCallback<R, Object>(
23 errorHandler as dynamic/*=ZoneUnaryCallback<R, dynamic>*/); 23 errorHandler as dynamic/*=ZoneUnaryCallback<R, Object>*/);
24 } 24 }
25 } 25 }
26
27 class _UncaughtAsyncError extends AsyncError {
28 _UncaughtAsyncError(error, StackTrace stackTrace)
29 : super(error, _getBestStackTrace(error, stackTrace));
30
31 static StackTrace _getBestStackTrace(error, StackTrace stackTrace) {
32 if (stackTrace != null) return stackTrace;
33 if (error is Error) {
34 return error.stackTrace;
35 }
36 return null;
37 }
38
39 String toString() {
40 String result = "Uncaught Error: ${error}";
41
42 if (stackTrace != null) {
43 result += "\nStack Trace:\n$stackTrace";
44 }
45 return result;
46 }
47 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/async/broadcast_stream_controller.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698