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

Unified Diff: pkg/source_maps/lib/span.dart

Issue 348493004: Add SpanException and SpanFormatException classes to source_maps. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 | « pkg/source_maps/CHANGELOG.md ('k') | pkg/source_maps/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/source_maps/lib/span.dart
diff --git a/pkg/source_maps/lib/span.dart b/pkg/source_maps/lib/span.dart
index f47e08eb629e81ce2c05a4414dcd5eee89f329cc..cc48f190d2e70988ef602aa46ea2ae915c7cf95c 100644
--- a/pkg/source_maps/lib/span.dart
+++ b/pkg/source_maps/lib/span.dart
@@ -360,3 +360,27 @@ class SourceFileSegment extends SourceFile {
String getText(int start, [int end]) =>
super.getText(start - _baseOffset, end == null ? null : end - _baseOffset);
}
+
+/// A class for exceptions that have source span information attached.
+class SpanException implements Exception {
+ /// A message describing the exception.
+ final String message;
+
+ /// The span associated with this exception.
+ ///
+ /// This may be `null` if the source location can't be determined.
+ final Span span;
+
+ SpanException(this.message, this.span);
+
+ String toString({bool useColors: false, String color}) {
+ if (span == null) return message;
+ return span.getLocationMessage(message, useColors: useColors, color: color);
+ }
+}
+
+/// A [SpanException] that's also a [FormatException].
+class SpanFormatException extends SpanException implements FormatException {
+ SpanFormatException(String message, Span span)
+ : super(message, span);
+}
« no previous file with comments | « pkg/source_maps/CHANGELOG.md ('k') | pkg/source_maps/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698