| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 test.runner.load_exception; | 5 library test.runner.load_exception; |
| 6 | 6 |
| 7 import 'dart:isolate'; | 7 import 'dart:isolate'; |
| 8 | 8 |
| 9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
| 10 import 'package:source_span/source_span.dart'; | 10 import 'package:source_span/source_span.dart'; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 if (color) buffer.write('\u001b[0m'); // no color | 25 if (color) buffer.write('\u001b[0m'); // no color |
| 26 | 26 |
| 27 var innerString = getErrorMessage(innerError); | 27 var innerString = getErrorMessage(innerError); |
| 28 if (innerError is IsolateSpawnException) { | 28 if (innerError is IsolateSpawnException) { |
| 29 // If this is a parse error, get rid of the noisy preamble. | 29 // If this is a parse error, get rid of the noisy preamble. |
| 30 innerString = innerString | 30 innerString = innerString |
| 31 .replaceFirst("'${p.toUri(p.absolute(path))}': error: ", ""); | 31 .replaceFirst("'${p.toUri(p.absolute(path))}': error: ", ""); |
| 32 | 32 |
| 33 // If this is a file system error, get rid of both the preamble and the | 33 // If this is a file system error, get rid of both the preamble and the |
| 34 // useless stack trace. | 34 // useless stack trace. |
| 35 |
| 36 // This message was used prior to 1.11.0-dev.3.0. |
| 35 innerString = innerString.replaceFirst( | 37 innerString = innerString.replaceFirst( |
| 36 "Unhandled exception:\n" | 38 "Unhandled exception:\n" |
| 37 "Uncaught Error: Load Error: ", | 39 "Uncaught Error: Load Error: ", |
| 38 ""); | 40 ""); |
| 41 |
| 42 // This message was used after 1.11.0-dev.3.0. |
| 43 innerString = innerString.replaceFirst( |
| 44 "Unhandled exception:\n" |
| 45 "Load Error for ", |
| 46 ""); |
| 47 |
| 39 innerString = innerString.replaceFirst("FileSystemException: ", ""); | 48 innerString = innerString.replaceFirst("FileSystemException: ", ""); |
| 40 innerString = innerString.split("Stack Trace:\n").first.trim(); | 49 innerString = innerString.split("Stack Trace:\n").first.trim(); |
| 41 } if (innerError is SourceSpanException) { | 50 } if (innerError is SourceSpanException) { |
| 42 innerString = innerError.toString(color: color) | 51 innerString = innerError.toString(color: color) |
| 43 .replaceFirst(" of $path", ""); | 52 .replaceFirst(" of $path", ""); |
| 44 } | 53 } |
| 45 | 54 |
| 46 buffer.write(innerString.contains("\n") ? "\n" : " "); | 55 buffer.write(innerString.contains("\n") ? "\n" : " "); |
| 47 buffer.write(innerString); | 56 buffer.write(innerString); |
| 48 return buffer.toString(); | 57 return buffer.toString(); |
| 49 } | 58 } |
| 50 } | 59 } |
| OLD | NEW |