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

Show more info for http error #372

Merged
merged 1 commit into from
Jul 5, 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
14 changes: 7 additions & 7 deletions wiliwili/include/api/bilibili/util/http.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class HTTP {
const ErrorCallback& error = nullptr) {
cpr::PostCallback(
[callback, error](const cpr::Response& r) {
if (r.status_code == 0) {
ERROR_MSG("No network connection", -1);
if (r.error) {
ERROR_MSG(r.error.message, -1);
return;
} else if (r.status_code != 200) {
ERROR_MSG("Network error. [Status code: " + std::to_string(r.status_code) + " ]", r.status_code);
Expand All @@ -66,8 +66,8 @@ class HTTP {
const ErrorCallback& error = nullptr) {
cpr::GetCallback(
[callback, error](const cpr::Response& r) {
if (r.status_code == 0) {
ERROR_MSG("No network connection", -1);
if (r.error) {
ERROR_MSG(r.error.message, -1);
return;
} else if (r.status_code != 200) {
ERROR_MSG("Network error. [Status code: " + std::to_string(r.status_code) + " ]", r.status_code);
Expand Down Expand Up @@ -116,10 +116,10 @@ class HTTP {
ERROR_MSG("Param error", -1);
}
} catch (const std::exception& e) {
if (r.status_code == 200) {
if (r.error) {
ERROR_MSG(r.error.message, -1);
} else if (r.status_code == 200) {
ERROR_MSG("Api error. \n" + std::string{e.what()}, 200);
} else if (r.status_code == 0) {
ERROR_MSG("No network connection", -1);
} else {
ERROR_MSG("Network error. \nStatus code: " + std::to_string(r.status_code), r.status_code);
}
Expand Down