diff --git a/wiliwili/include/api/bilibili/util/http.hpp b/wiliwili/include/api/bilibili/util/http.hpp index dab85803..5942faa9 100644 --- a/wiliwili/include/api/bilibili/util/http.hpp +++ b/wiliwili/include/api/bilibili/util/http.hpp @@ -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); @@ -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); @@ -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); }