Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redfishpower: output extra error info #97

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading