log red on server errors when publishing, or green on success (#1707)
diff --git a/lib/src/command/lish.dart b/lib/src/command/lish.dart
index cceee42..133dbbf 100644
--- a/lib/src/command/lish.dart
+++ b/lib/src/command/lish.dart
@@ -103,7 +103,7 @@
// TODO(nweiz): the response may have XML-formatted information about
// the error. Try to parse that out once we have an easily-accessible
// XML parser.
- fail('Failed to upload the package.');
+ fail(log.red('Failed to upload the package.'));
} else if (urisEqual(Uri.parse(url.origin), Uri.parse(server.origin))) {
handleJsonError(error.response);
} else {
diff --git a/lib/src/http.dart b/lib/src/http.dart
index 23630d7..aaaca2e 100644
--- a/lib/src/http.dart
+++ b/lib/src/http.dart
@@ -240,7 +240,7 @@
parsed['success']['message'] is! String) {
invalidServerResponse(response);
}
- log.message(parsed['success']['message']);
+ log.message(log.green(parsed['success']['message']));
}
/// Handles an unsuccessful JSON-formatted response from pub.dartlang.org.
@@ -255,7 +255,7 @@
errorMap['error']['message'] is! String) {
invalidServerResponse(response);
}
- fail(errorMap['error']['message']);
+ fail(log.red(errorMap['error']['message']));
}
/// Parses a response body, assuming it's JSON-formatted.
@@ -275,7 +275,7 @@
/// Throws an error describing an invalid response from the server.
void invalidServerResponse(http.Response response) =>
- fail('Invalid server response:\n${response.body}');
+ fail(log.red('Invalid server response:\n${response.body}'));
/// Exception thrown when an HTTP operation fails.
class PubHttpException implements Exception {