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

Unified Diff: pkg/barback/lib/src/errors.dart

Issue 196223005: Pre-compute the stack chain in Barback's _WrappedException. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 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/barback/lib/src/errors.dart
diff --git a/pkg/barback/lib/src/errors.dart b/pkg/barback/lib/src/errors.dart
index d62efeb1f8959a568d21ff6f511f385fef743eee..5303b9d5629fc041bd6cea0d6675912d47567f8b 100644
--- a/pkg/barback/lib/src/errors.dart
+++ b/pkg/barback/lib/src/errors.dart
@@ -115,25 +115,26 @@ abstract class _WrappedException implements BarbackException {
final error;
final Chain stackTrace;
- _WrappedException(this.error, StackTrace stackTrace)
- : this.stackTrace = stackTrace == null ? null :
- new Chain.forTrace(stackTrace);
+ _WrappedException(error, StackTrace stackTrace)
+ : this.error = error,
+ this.stackTrace = _getChain(error, stackTrace);
String get _message;
String toString() {
var result = "$_message: $error";
-
- var stack = stackTrace;
- if (stack == null && error is Error) stack = error.stackTrace;
- if (stack != null) {
- result = "$result\n${stackTrace.terse}";
- }
-
+ if (stackTrace != null) result = "$result\n${stackTrace.terse}";
return result;
}
}
+/// Returns the stack chain for [error] and [stackTrace].
+Chain _getChain(error, StackTrace stackTrace) {
+ if (error is Error && stackTrace == null) stackTrace = error.stackTrace;
+ if (stackTrace != null) return new Chain.forTrace(stackTrace);
+ return null;
+}
+
/// Error wrapping an exception thrown by a transform.
class TransformerException extends _WrappedException {
/// The transform that threw the exception.
« 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