| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // TODO(lrn): This should be in package:async? | 5 // TODO(lrn): This should be in package:async? |
| 6 /// Helper functions for working with errors. | 6 /// Helper functions for working with errors. |
| 7 /// | 7 /// |
| 8 /// The [MultiError] class combines multiple errors into one object, | 8 /// The [MultiError] class combines multiple errors into one object, |
| 9 /// and the [MultiError.wait] function works like [Future.wait] except | 9 /// and the [MultiError.wait] function works like [Future.wait] except |
| 10 /// that it returns all the errors. | 10 /// that it returns all the errors. |
| 11 library pkg.isolate.errors; | 11 library isolate.errors; |
| 12 | 12 |
| 13 import "dart:async"; | 13 import 'dart:async'; |
| 14 | 14 |
| 15 class MultiError extends Error { | 15 class MultiError extends Error { |
| 16 // Limits the number of lines included from each error's error message. | 16 // Limits the number of lines included from each error's error message. |
| 17 // A best-effort attempt is made at keeping below this number of lines | 17 // A best-effort attempt is made at keeping below this number of lines |
| 18 // in the output. | 18 // in the output. |
| 19 // If there are too many errors, they will all get at least one line. | 19 // If there are too many errors, they will all get at least one line. |
| 20 static const int _MAX_LINES = 55; | 20 static const int _MAX_LINES = 55; |
| 21 // Minimum number of lines in the toString for each error. | 21 // Minimum number of lines in the toString for each error. |
| 22 static const int _MIN_LINES_PER_ERROR = 1; | 22 static const int _MIN_LINES_PER_ERROR = 1; |
| 23 | 23 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 169 } |
| 170 buffer.write("#$index: "); | 170 buffer.write("#$index: "); |
| 171 buffer.write(errorString.substring(0, end)); | 171 buffer.write(errorString.substring(0, end)); |
| 172 if (end < errorString.length) { | 172 if (end < errorString.length) { |
| 173 buffer.write("...\n"); | 173 buffer.write("...\n"); |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 return buffer.toString(); | 176 return buffer.toString(); |
| 177 } | 177 } |
| 178 } | 178 } |
| OLD | NEW |