From 8afd7d214f6e64d5622451b97ecd9205fd17333b Mon Sep 17 00:00:00 2001 From: Ferran Basora Date: Thu, 8 Nov 2018 19:47:53 +0000 Subject: [PATCH] Red errors --- src/actions/request.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/actions/request.rs b/src/actions/request.rs index f6b5e07..55dc409 100644 --- a/src/actions/request.rs +++ b/src/actions/request.rs @@ -137,7 +137,13 @@ impl Request { let response = response_result.unwrap(); let duration_ms = (time::precise_time_s() - begin) * 1000.0; - println!("{:width$} {} {} {}{}", interpolated_name.green(), interpolated_url.blue().bold(), response.status.to_string().yellow(), duration_ms.round().to_string().cyan(), "ms".cyan(), width=25); + let status_text = if response.status.is_server_error() { + response.status.to_string().red() + } else { + response.status.to_string().yellow() + }; + + println!("{:width$} {} {} {}{}", interpolated_name.green(), interpolated_url.blue().bold(), status_text, duration_ms.round().to_string().cyan(), "ms".cyan(), width=25); (response, duration_ms) }