remoced errors 20-25
This commit is contained in:
parent
bbdcf70efd
commit
53c8bb7b4c
@ -1,6 +1,6 @@
|
||||
cmake_minimum_required (VERSION 3.7)
|
||||
project (mastodon-cpp
|
||||
VERSION 0.8.8
|
||||
VERSION 0.8.9
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
|
39
README.md
39
README.md
@ -12,7 +12,11 @@ There are [examples](https://github.com/tastytea/mastodon-cpp/tree/master/exampl
|
||||
|
||||
## Upgrading from below 0.7.0
|
||||
|
||||
The header location has changed. They are now in `mastodon-cpp/`.
|
||||
Your projects will break, sorry. Here are the important changes:
|
||||
|
||||
* The header location has changed. They are now in `mastodon-cpp/`.
|
||||
* Specific network error messages have been replaced by 15, "Network error".
|
||||
You can get the exceptions from curlpp with `Mastodon::API::exceptions(true)`.
|
||||
|
||||
## Most basic example
|
||||
|
||||
@ -68,23 +72,24 @@ A project consisting of one file can be compiled as follows:
|
||||
|
||||
mastodon-cpp will never use error codes below 11, except 0.
|
||||
|
||||
| Code | Explanation |
|
||||
| --------: |:------------------------------|
|
||||
| 0 | No error |
|
||||
| 11 | Invalid call |
|
||||
| 12 | Not implemented |
|
||||
| 13 | URL changed (HTTP 301 or 308) |
|
||||
| 14 | Aborted by user |
|
||||
| 20 | Failed to connect |
|
||||
| 21 | Couldn't resolve host |
|
||||
| 22 | Network is unreachable |
|
||||
| 23 | Transfer interrupted |
|
||||
| 24 | SSL error |
|
||||
| 25 | Timeout |
|
||||
| 100 - 999 | HTTP status codes |
|
||||
| 65535 | Unknown error |
|
||||
| Code | Explanation |
|
||||
| --------: |:---------------------------------|
|
||||
| 0 | No error |
|
||||
| 11 | Invalid call |
|
||||
| 12 | Not implemented |
|
||||
| 13 | URL changed (HTTP 301 or 308) |
|
||||
| 14 | Aborted by user |
|
||||
| 15 | Network error (curlpp exception) |
|
||||
| ~~20~~ | ~~Failed to connect~~ |
|
||||
| ~~21~~ | ~~Couldn't resolve host~~ |
|
||||
| ~~22~~ | ~~Network is unreachable~~ |
|
||||
| ~~23~~ | ~~Transfer interrupted~~ |
|
||||
| ~~24~~ | ~~SSL error~~ |
|
||||
| ~~25~~ | ~~Timeout~~ |
|
||||
| 100 - 999 | HTTP status codes |
|
||||
| 65535 | Unknown error |
|
||||
|
||||
If you use a debug build, you get more verbose error messages.
|
||||
If you use a debug build, you get more verbose error messages. Errors 20-25 are no longer in use (since 0.8.9).
|
||||
|
||||
## Useful links
|
||||
|
||||
|
54
src/http.cpp
54
src/http.cpp
@ -137,58 +137,22 @@ const uint_fast16_t API::http::request(const method &meth,
|
||||
}
|
||||
catch (curlpp::RuntimeError &e)
|
||||
{
|
||||
if (parent.exceptions())
|
||||
{
|
||||
std::rethrow_exception(std::current_exception());
|
||||
}
|
||||
|
||||
// FIXME: There has to be a better way
|
||||
if (std::strncmp(e.what(),
|
||||
"Failed writing body", 19) == 0)
|
||||
// This error is thrown if http.abort_stream() is used.
|
||||
if (std::strncmp(e.what(), "Failed writing body", 19) == 0)
|
||||
{
|
||||
ttdebug << "Request was aborted by user\n";
|
||||
return 14;
|
||||
}
|
||||
else if (std::strncmp(e.what(),
|
||||
"Failed to connect to", 20) == 0)
|
||||
|
||||
if (parent.exceptions())
|
||||
{
|
||||
ret = 20;
|
||||
}
|
||||
else if (std::strncmp(e.what(),
|
||||
"Couldn't resolve host", 21) == 0 ||
|
||||
std::strncmp(e.what(),
|
||||
"Could not resolve host", 22) == 0)
|
||||
{
|
||||
ret = 21;
|
||||
}
|
||||
else if (std::strncmp(e.what(),
|
||||
"Network is unreachable", 22) == 0)
|
||||
{
|
||||
ret = 22;
|
||||
}
|
||||
else if (std::strncmp(e.what(),
|
||||
"transfer closed with outstanding", 32) == 0)
|
||||
{
|
||||
ret = 23;
|
||||
}
|
||||
else if (std::strncmp(e.what(),
|
||||
"OpenSSL SSL_read: SSL_ERROR_SYSCALL", 35) == 0)
|
||||
{
|
||||
ret = 24;
|
||||
}
|
||||
else if (std::strncmp(e.what(),
|
||||
"Operation timed out", 19) == 0)
|
||||
{
|
||||
ret = 25;
|
||||
std::rethrow_exception(std::current_exception());
|
||||
}
|
||||
else
|
||||
{
|
||||
cerr << "RUNTIME ERROR: " << e.what() << std::endl;
|
||||
ret = 0xffff;
|
||||
ttdebug << "curlpp::RuntimeError: " << e.what() << std::endl;
|
||||
return 15;
|
||||
}
|
||||
ttdebug << e.what() << std::endl;
|
||||
|
||||
return ret;
|
||||
}
|
||||
catch (curlpp::LogicError &e)
|
||||
{
|
||||
@ -197,8 +161,8 @@ const uint_fast16_t API::http::request(const method &meth,
|
||||
std::rethrow_exception(std::current_exception());
|
||||
}
|
||||
|
||||
cerr << "LOGIC ERROR: " << e.what() << std::endl;
|
||||
return 0xffff;
|
||||
ttdebug << "curlpp::LogicError: " << e.what() << std::endl;
|
||||
return 15;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -57,21 +57,18 @@ namespace Mastodon
|
||||
*
|
||||
* @section error Error codes
|
||||
* mastodon-cpp will never use error codes below 11, except 0.
|
||||
* | Code | Explanation |
|
||||
* | --------: |:------------------------------|
|
||||
* | 0 | No error |
|
||||
* | 11 | Invalid call |
|
||||
* | 12 | Not implemented |
|
||||
* | 13 | URL changed (HTTP 301 or 308) |
|
||||
* | 14 | Aborted by user |
|
||||
* | 20 | Failed to connect |
|
||||
* | 21 | Couldn't resolve host |
|
||||
* | 22 | Network is unreachable |
|
||||
* | 23 | Transfer interrupted |
|
||||
* | 24 | SSL error |
|
||||
* | 25 | Timeout |
|
||||
* | 100 - 999 | HTTP status codes |
|
||||
* | 65535 | Unknown exception |
|
||||
* | Code | Explanation |
|
||||
* | --------: |:---------------------------------|
|
||||
* | 0 | No error |
|
||||
* | 11 | Invalid call |
|
||||
* | 12 | Not implemented |
|
||||
* | 13 | URL changed (HTTP 301 or 308) |
|
||||
* | 14 | Aborted by user |
|
||||
* | 15 | Network error (curlpp exception) |
|
||||
* | 100 - 999 | HTTP status codes |
|
||||
* | 65535 | Unknown error |
|
||||
*
|
||||
* @deprecated Errors 20-25 are no longer in use.
|
||||
*/
|
||||
class API
|
||||
{
|
||||
|
Reference in New Issue
Block a user