Index: pkg/barback/lib/src/utils.dart |
diff --git a/pkg/barback/lib/src/utils.dart b/pkg/barback/lib/src/utils.dart |
index d5a9fb62dd1130684c73390fd2904d7f7ccafbff..c26c7e8f0cbebd1f4117627d9bb8d3553f1900d5 100644 |
--- a/pkg/barback/lib/src/utils.dart |
+++ b/pkg/barback/lib/src/utils.dart |
@@ -325,3 +325,14 @@ Stream broadcastToSingleSubscription(Stream broadcast) { |
onDone: controller.close); |
return controller.stream; |
} |
+ |
+/// 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, ''); |