Commit bd30ad58b71c9305bfb39ad75fae549734506b6a
1 parent
3d500e3c
Improve error messages of BaseHttpHandler
- Rename IHttpHandler to BaseHttpHandler in debug messages - Add more informative debug print when the body of a response could not be found
Showing
1 changed file
with
8 additions
and
4 deletions
hueplusplus/include/BaseHttpHandler.h
| ... | ... | @@ -56,8 +56,12 @@ public: |
| 56 | 56 | size_t start = response.find("\r\n\r\n"); |
| 57 | 57 | if (start == std::string::npos) |
| 58 | 58 | { |
| 59 | - std::cerr << "IHttpHandler: Failed to find body in response\n"; | |
| 60 | - throw(std::runtime_error("IHttpHandler: Failed to find body in response")); | |
| 59 | + std::cerr << "BaseHttpHandler: Failed to find body in response\n"; | |
| 60 | + std::cerr << "Request:\n"; | |
| 61 | + std::cerr << "\"" << msg << "\"\n"; | |
| 62 | + std::cerr << "Response:\n"; | |
| 63 | + std::cerr << "\"" << response << "\"\n"; | |
| 64 | + throw(std::runtime_error("BaseHttpHandler: Failed to find body in response")); | |
| 61 | 65 | } |
| 62 | 66 | response.erase(0, start + 4); |
| 63 | 67 | return response; |
| ... | ... | @@ -231,8 +235,8 @@ private: |
| 231 | 235 | std::unique_ptr<Json::CharReader> reader = std::unique_ptr<Json::CharReader>(builder.newCharReader()); |
| 232 | 236 | if (!reader->parse(str.c_str(), str.c_str() + str.length(), &result, &error)) |
| 233 | 237 | { |
| 234 | - std::cerr << "IHttpHandler: Error while parsing JSON in function strToJsonValue(): " << error << std::endl; | |
| 235 | - throw(std::runtime_error("IHttpHandler: Error while parsing JSON in function strToJsonValue()")); | |
| 238 | + std::cerr << "BaseHttpHandler: Error while parsing JSON in function strToJsonValue(): " << error << std::endl; | |
| 239 | + throw(std::runtime_error("BaseHttpHandler: Error while parsing JSON in function strToJsonValue()")); | |
| 236 | 240 | } |
| 237 | 241 | return result; |
| 238 | 242 | } | ... | ... |