OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library fasta.errors; | 5 library fasta.errors; |
6 | 6 |
7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
8 | 8 |
9 import 'dart:convert' show JSON; | 9 import 'dart:convert' show JSON; |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 /// Used to report an error in input. | 44 /// Used to report an error in input. |
45 /// | 45 /// |
46 /// Avoid using this for reporting compile-time errors, instead use | 46 /// Avoid using this for reporting compile-time errors, instead use |
47 /// `LibraryBuilder.addCompileTimeError` for those. | 47 /// `LibraryBuilder.addCompileTimeError` for those. |
48 /// | 48 /// |
49 /// An input error is any error that isn't an internal error. We use the term | 49 /// An input error is any error that isn't an internal error. We use the term |
50 /// "input error" in favor of "user error". This way, if an input error isn't | 50 /// "input error" in favor of "user error". This way, if an input error isn't |
51 /// handled correctly, the user will never see a stack trace that says "user | 51 /// handled correctly, the user will never see a stack trace that says "user |
52 /// error". | 52 /// error". |
53 dynamic inputError(Uri uri, int charOffset, Object error) { | 53 dynamic inputError(Uri uri, int charOffset, Object error) { |
| 54 if (errorsAreFatal && isVerbose) { |
| 55 print(StackTrace.current); |
| 56 } |
54 throw new InputError(uri, charOffset, error); | 57 throw new InputError(uri, charOffset, error); |
55 } | 58 } |
56 | 59 |
57 String printUnexpected(Uri uri, int charOffset, String message) { | 60 String printUnexpected(Uri uri, int charOffset, String message) { |
58 String formattedMessage = formatUnexpected(uri, charOffset, message); | 61 String formattedMessage = formatUnexpected(uri, charOffset, message); |
59 if (errorsAreFatal) { | 62 if (errorsAreFatal) { |
60 print(formattedMessage); | 63 print(formattedMessage); |
61 if (isVerbose) print(StackTrace.current); | 64 if (isVerbose) print(StackTrace.current); |
62 throw new InputError(uri, charOffset, message); | 65 throw new InputError(uri, charOffset, message); |
63 } | 66 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 return new Future.error(error, trace); | 174 return new Future.error(error, trace); |
172 } | 175 } |
173 | 176 |
174 String safeToString(Object object) { | 177 String safeToString(Object object) { |
175 try { | 178 try { |
176 return "$object"; | 179 return "$object"; |
177 } catch (e) { | 180 } catch (e) { |
178 return "Error when converting ${object.runtimeType} to string."; | 181 return "Error when converting ${object.runtimeType} to string."; |
179 } | 182 } |
180 } | 183 } |
OLD | NEW |