Skip to content

Commit cde958f

Browse files
authored
log red on server errors when publishing, or green on success (#1707)
1 parent 04c7827 commit cde958f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/src/command/lish.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class LishCommand extends PubCommand {
103103
// TODO(nweiz): the response may have XML-formatted information about
104104
// the error. Try to parse that out once we have an easily-accessible
105105
// XML parser.
106-
fail('Failed to upload the package.');
106+
fail(log.red('Failed to upload the package.'));
107107
} else if (urisEqual(Uri.parse(url.origin), Uri.parse(server.origin))) {
108108
handleJsonError(error.response);
109109
} else {

lib/src/http.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ void handleJsonSuccess(http.Response response) {
240240
parsed['success']['message'] is! String) {
241241
invalidServerResponse(response);
242242
}
243-
log.message(parsed['success']['message']);
243+
log.message(log.green(parsed['success']['message']));
244244
}
245245

246246
/// Handles an unsuccessful JSON-formatted response from pub.dartlang.org.
@@ -255,7 +255,7 @@ void handleJsonError(http.Response response) {
255255
errorMap['error']['message'] is! String) {
256256
invalidServerResponse(response);
257257
}
258-
fail(errorMap['error']['message']);
258+
fail(log.red(errorMap['error']['message']));
259259
}
260260

261261
/// Parses a response body, assuming it's JSON-formatted.
@@ -275,7 +275,7 @@ Map parseJsonResponse(http.Response response) {
275275

276276
/// Throws an error describing an invalid response from the server.
277277
void invalidServerResponse(http.Response response) =>
278-
fail('Invalid server response:\n${response.body}');
278+
fail(log.red('Invalid server response:\n${response.body}'));
279279

280280
/// Exception thrown when an HTTP operation fails.
281281
class PubHttpException implements Exception {

0 commit comments

Comments
 (0)