| Index: lib/src/utils.dart
|
| diff --git a/lib/src/utils.dart b/lib/src/utils.dart
|
| index da2192764a1af63e56830205f26e5129dc3acd06..5c12593e4f4bd8864c07210b527dab933c905340 100644
|
| --- a/lib/src/utils.dart
|
| +++ b/lib/src/utils.dart
|
| @@ -13,6 +13,17 @@ import 'package:stack_trace/stack_trace.dart';
|
| /// The return type should only ever by [Future] or void.
|
| typedef AsyncFunction();
|
|
|
| +/// A regular expression to match the exception prefix that some exceptions'
|
| +/// [Object.toString] values contain.
|
| +final _exceptionPrefix = new RegExp(r'^([A-Z][a-zA-Z]*)?(Exception|Error): ');
|
| +
|
| +/// Get a string description of an exception.
|
| +///
|
| +/// Many exceptions include the exception class name at the beginning of their
|
| +/// [toString], so we remove that if it exists.
|
| +String getErrorMessage(error) =>
|
| + error.toString().replaceFirst(_exceptionPrefix, '');
|
| +
|
| /// Indent each line in [str] by two spaces.
|
| String indent(String str) =>
|
| str.replaceAll(new RegExp("^", multiLine: true), " ");
|
| @@ -34,6 +45,25 @@ class Pair<E, F> {
|
| int get hashCode => first.hashCode ^ last.hashCode;
|
| }
|
|
|
| +/// A regular expression matching the path to a temporary file used to start an
|
| +/// isolate.
|
| +///
|
| +/// These paths aren't relevant and are removed from stack traces.
|
| +final _isolatePath =
|
| + new RegExp(r"/unittest_[A-Za-z0-9]{6}/runInIsolate\.dart$");
|
| +
|
| +/// Returns [stackTrace] converted to a [Chain] with all irrelevant frames
|
| +/// folded together.
|
| +Chain terseChain(StackTrace stackTrace) {
|
| + return new Chain.forTrace(stackTrace).foldFrames((frame) {
|
| + if (frame.package == 'unittest') return true;
|
| +
|
| + // Filter out frames from our isolate bootstrap as well.
|
| + if (frame.uri.scheme != 'file') return false;
|
| + return frame.uri.path.contains(_isolatePath);
|
| + }, terse: true);
|
| +}
|
| +
|
| /// Returns a Trace object from a StackTrace object or a String, or the
|
| /// unchanged input if formatStacks is false;
|
| Trace getTrace(stack, bool formatStacks, bool filterStacks) {
|
|
|