mirror of
https://github.com/moparisthebest/spdylay
synced 2024-12-22 07:38:52 -05:00
Added spdylay_strerror() public API.
This commit is contained in:
parent
c68a0b5e6d
commit
d377fe0dc6
@ -407,13 +407,6 @@ void on_ctrl_recv_callback
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
namespace {
|
||||
const char* spdylay_strerror(int error_code)
|
||||
{
|
||||
return "UNKNOWN";
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
void dump_header(const uint8_t *head, size_t headlen)
|
||||
{
|
||||
@ -436,8 +429,9 @@ void on_ctrl_recv_parse_error_callback(spdylay_session *session,
|
||||
int error_code, void *user_data)
|
||||
{
|
||||
print_timer();
|
||||
printf(" recv %s frame: Parse error [%s]\n", ctrl_names[type-1],
|
||||
spdylay_strerror(error_code));
|
||||
printf(" recv %s frame: Parse error\n", ctrl_names[type-1]);
|
||||
print_frame_attr_indent();
|
||||
printf("Error: %s\n", spdylay_strerror(error_code));
|
||||
dump_header(head, headlen);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
@ -1557,6 +1557,14 @@ uint8_t spdylay_session_get_pri_lowest(spdylay_session *session);
|
||||
int spdylay_session_fail_session(spdylay_session *session,
|
||||
uint32_t status_code);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* Returns string describing the |error_code|. The |error_code| must
|
||||
* be one of the :enum:`spdylay_error`.
|
||||
*/
|
||||
const char* spdylay_strerror(int error_code);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
|
@ -71,3 +71,55 @@ int spdylay_reserve_buffer(uint8_t **buf_ptr, size_t *buflen_ptr,
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* spdylay_strerror(int error_code)
|
||||
{
|
||||
switch(error_code) {
|
||||
case SPDYLAY_ERR_INVALID_ARGUMENT:
|
||||
return "Invalid argument";
|
||||
case SPDYLAY_ERR_ZLIB:
|
||||
return "Zlib error";
|
||||
case SPDYLAY_ERR_UNSUPPORTED_VERSION:
|
||||
return "Unsupported SPDY version";
|
||||
case SPDYLAY_ERR_WOULDBLOCK:
|
||||
return "Operation would block";
|
||||
case SPDYLAY_ERR_PROTO:
|
||||
return "Protocol error";
|
||||
case SPDYLAY_ERR_INVALID_FRAME:
|
||||
return "Invalid frame octets";
|
||||
case SPDYLAY_ERR_EOF:
|
||||
return "EOF";
|
||||
case SPDYLAY_ERR_DEFERRED:
|
||||
return "Data transfer deferred";
|
||||
case SPDYLAY_ERR_STREAM_ID_NOT_AVAILABLE:
|
||||
return "No more Stream ID available";
|
||||
case SPDYLAY_ERR_STREAM_CLOSED:
|
||||
return "Stream was already closed or invalid";
|
||||
case SPDYLAY_ERR_STREAM_CLOSING:
|
||||
return "Stream is closing";
|
||||
case SPDYLAY_ERR_STREAM_SHUT_WR:
|
||||
return "The transmission is not allowed for this stream";
|
||||
case SPDYLAY_ERR_INVALID_STREAM_ID:
|
||||
return "Stream ID is invalid";
|
||||
case SPDYLAY_ERR_INVALID_STREAM_STATE:
|
||||
return "Invalid stream state";
|
||||
case SPDYLAY_ERR_DEFERRED_DATA_EXIST:
|
||||
return "Another DATA frame has already been deferred";
|
||||
case SPDYLAY_ERR_SYN_STREAM_NOT_ALLOWED:
|
||||
return "SYN_STREAM is not allowed";
|
||||
case SPDYLAY_ERR_GOAWAY_ALREADY_SENT:
|
||||
return "GOAWAY has already been sent";
|
||||
case SPDYLAY_ERR_INVALID_HEADER_BLOCK:
|
||||
return "Invalid header block";
|
||||
case SPDYLAY_ERR_INVALID_STATE:
|
||||
return "Invalid state";
|
||||
case SPDYLAY_ERR_GZIP:
|
||||
return "Gzip error";
|
||||
case SPDYLAY_ERR_NOMEM:
|
||||
return "Out of memory";
|
||||
case SPDYLAY_ERR_CALLBACK_FAILURE:
|
||||
return "The user callback function failed";
|
||||
default:
|
||||
return "Unknown error code";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user