Make StringScannerException extend SpanFormatException.
R=rnystrom@google.com
BUG=
Review URL: https://codereview.chromium.org//343043002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/string_scanner@37619 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2c41c9d..a5d5518 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,10 @@
+## 0.0.3
+
+* Make `StringScannerException` inherit from source_map's
+ [`SpanFormatException`][].
+
+[SpanFormatException]: (http://www.dartdocs.org/documentation/source_maps/0.9.2/index.html#source_maps/source_maps.SpanFormatException)
+
## 0.0.2
* `new StringScanner()` now takes an optional `sourceUrl` argument that provides
diff --git a/lib/src/exception.dart b/lib/src/exception.dart
index c398687..44ec9a3 100644
--- a/lib/src/exception.dart
+++ b/lib/src/exception.dart
@@ -7,10 +7,7 @@
import 'package:source_maps/source_maps.dart';
/// An exception thrown by a [StringScanner] that failed to parse a string.
-class StringScannerException implements FormatException {
- /// The error message.
- final String message;
-
+class StringScannerException extends SpanFormatException {
/// The source string being parsed.
final String string;
@@ -19,19 +16,6 @@
/// This may be `null`, indicating that the source URL is unknown.
final Uri sourceUrl;
- /// The span within [string] that caused the exception.
- final Span span;
-
- StringScannerException(this.message, this.string, this.sourceUrl, this.span);
-
- /// Returns a detailed description of this exception.
- ///
- /// If [useColors] is true, the section of the source that caused the
- /// exception will be colored using ANSI color codes. By default, it's colored
- /// red, but a different ANSI code may passed via [color].
- String toString({bool useColors: false, String color}) {
- return "Error on " + span.getLocationMessage(
- message, useColors: useColors, color: color);
- }
+ StringScannerException(String message, this.string, this.sourceUrl, Span span)
+ : super(message, span);
}
-
diff --git a/pubspec.yaml b/pubspec.yaml
index 86ae238..f6d7ab9 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,12 +1,12 @@
name: string_scanner
-version: 0.0.2
+version: 0.0.3
author: "Dart Team <misc@dartlang.org>"
homepage: http://www.dartlang.org
description: >
A class for parsing strings using a sequence of patterns.
dependencies:
path: ">=1.2.0 <2.0.0"
- source_maps: ">=0.9.0 <0.10.0"
+ source_maps: ">=0.9.2 <0.10.0"
dev_dependencies:
unittest: ">=0.10.0 <0.11.0"
environment: