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

Side by Side Diff: pkg/source_span/lib/src/source_span_exception.dart

Issue 381363002: Extract out a source_span package from source_maps. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library source_span.source_span_exception;
6
7 import 'source_span.dart';
8
9 /// A class for exceptions that have source span information attached.
10 class SourceSpanException implements Exception {
11 /// A message describing the exception.
12 final String message;
13
14 /// The span associated with this exception.
15 ///
16 /// This may be `null` if the source location can't be determined.
17 final SourceSpan span;
18
19 SourceSpanException(this.message, this.span);
20
21 /// Returns a string representation of [this].
22 ///
23 /// [color] may either be a [String], a [bool], or `null`. If it's a string,
24 /// it indicates an ANSII terminal color escape that should be used to
25 /// highlight the span's text. If it's `true`, it indicates that the text
26 /// should be highlighted using the default color. If it's `false` or `null`,
27 /// it indicates that the text shouldn't be highlighted.
28 String toString({color}) {
29 if (span == null) return message;
30 return "Error on " + span.message(message, color: color);
31 }
32 }
33
34 /// A [SourceSpanException] that's also a [FormatException].
35 class SourceSpanFormatException extends SourceSpanException
36 implements FormatException {
37 SourceSpanFormatException(String message, SourceSpan span)
38 : super(message, span);
Siggi Cherem (dart-lang) 2014/07/16 21:26:10 there were some changes in the source_maps package
nweiz 2014/07/17 20:22:08 Done.
39 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698