diff mbox series

channel_curl: log 403 HTTP errors

Message ID 20181220113921.14369-1-diego.rondini@kynetics.com
State Accepted
Headers show
Series channel_curl: log 403 HTTP errors | expand

Commit Message

Diego Rondini Dec. 20, 2018, 11:39 a.m. UTC
Signed-off-by: Diego Rondini <diego.rondini@kynetics.com>
---
 corelib/channel_curl.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Stefano Babic Dec. 20, 2018, 1:43 p.m. UTC | #1
On 20/12/18 12:39, Diego Rondini wrote:
> Signed-off-by: Diego Rondini <diego.rondini@kynetics.com>
> ---
>  corelib/channel_curl.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c
> index e81f631..05fe5fe 100644
> --- a/corelib/channel_curl.c
> +++ b/corelib/channel_curl.c
> @@ -1106,11 +1106,14 @@ channel_op_res_t channel_get(channel_t *this, void *data)
>  	    CHANNEL_OK) {
>  		ERROR("Channel operation returned HTTP error code %ld.",
>  		      http_response_code);
> -		if (http_response_code == 500) {
> -			DEBUG("The error's message is: '%s'", chunk.memory);
> -		}
> -		if (http_response_code == 404) {
> -			DEBUG("The error's message is: '%s'", chunk.memory);
> +		switch (http_response_code) {
> +			case 403:
> +			case 404:
> +			case 500:
> +				DEBUG("The error's message is: '%s'\n", chunk.memory);
> +				break;
> +			default:
> +				break;
>  		}
>  		goto cleanup_chunk;
>  	}
> 

Acked-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c
index e81f631..05fe5fe 100644
--- a/corelib/channel_curl.c
+++ b/corelib/channel_curl.c
@@ -1106,11 +1106,14 @@  channel_op_res_t channel_get(channel_t *this, void *data)
 	    CHANNEL_OK) {
 		ERROR("Channel operation returned HTTP error code %ld.",
 		      http_response_code);
-		if (http_response_code == 500) {
-			DEBUG("The error's message is: '%s'", chunk.memory);
-		}
-		if (http_response_code == 404) {
-			DEBUG("The error's message is: '%s'", chunk.memory);
+		switch (http_response_code) {
+			case 403:
+			case 404:
+			case 500:
+				DEBUG("The error's message is: '%s'\n", chunk.memory);
+				break;
+			default:
+				break;
 		}
 		goto cleanup_chunk;
 	}