OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 import 'span.dart'; | 5 import 'span.dart'; |
6 | 6 |
7 /// A class for exceptions that have source span information attached. | 7 /// A class for exceptions that have source span information attached. |
8 class SourceSpanException implements Exception { | 8 class SourceSpanException implements Exception { |
9 /// A message describing the exception. | 9 /// A message describing the exception. |
10 final String message; | 10 final String message; |
(...skipping 14 matching lines...) Expand all Loading... |
25 /// it indicates that the text shouldn't be highlighted. | 25 /// it indicates that the text shouldn't be highlighted. |
26 String toString({color}) { | 26 String toString({color}) { |
27 if (span == null) return message; | 27 if (span == null) return message; |
28 return "Error on " + span.message(message, color: color); | 28 return "Error on " + span.message(message, color: color); |
29 } | 29 } |
30 } | 30 } |
31 | 31 |
32 /// A [SourceSpanException] that's also a [FormatException]. | 32 /// A [SourceSpanException] that's also a [FormatException]. |
33 class SourceSpanFormatException extends SourceSpanException | 33 class SourceSpanFormatException extends SourceSpanException |
34 implements FormatException { | 34 implements FormatException { |
35 final source; | 35 final _source; |
| 36 |
| 37 // Subclasses may narrow the type. |
| 38 dynamic get source => _source; |
36 | 39 |
37 int get offset => span == null ? null : span.start.offset; | 40 int get offset => span == null ? null : span.start.offset; |
38 | 41 |
39 SourceSpanFormatException(String message, SourceSpan span, [this.source]) | 42 SourceSpanFormatException(String message, SourceSpan span, [this._source]) |
40 : super(message, span); | 43 : super(message, span); |
41 } | 44 } |
OLD | NEW |