Skip to content

Commit

Permalink
Merge pull request #97 from chu11/redfishpower_moreerrors
Browse files Browse the repository at this point in the history
redfishpower: output extra error info
  • Loading branch information
mergify[bot] committed Jan 27, 2024
2 parents 2754c00 + b161c21 commit a6dcd66
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/redfishpower/redfishpower.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,31 @@ static void shell(CURLM *mh)
err_exit(false, "private data not set in easy handle");

if (cmsg->data.result != 0) {
printf("%s: %s\n", pm->hostname, "error");
if (cmsg->data.result == CURLE_COULDNT_CONNECT
|| cmsg->data.result == CURLE_OPERATION_TIMEDOUT)
printf("%s: %s\n", pm->hostname, "network error");
else if (cmsg->data.result == CURLE_HTTP_RETURNED_ERROR) {
/* N.B. curl returns this error code for all response
* codes >= 400. So gotta dig in more.
*/
long code;

if (curl_easy_getinfo(cmsg->easy_handle,
CURLINFO_RESPONSE_CODE,
&code) != CURLE_OK)
printf("%s: %s\n", pm->hostname, "http error");
if (code == 401)
printf("%s: %s\n", pm->hostname, "unauthorized");
else if (code == 404)
printf("%s: %s\n", pm->hostname, "not found");
else
printf("%s: %s (%ld)\n",
pm->hostname,
"http error",
code);
}
else
printf("%s: %s\n", pm->hostname, "error");
if (verbose)
printf("%s: %s\n", pm->hostname,
curl_easy_strerror(cmsg->data.result));
Expand Down

0 comments on commit a6dcd66

Please sign in to comment.