reorganized error codes

This commit is contained in:
Arvid Norberg
2009-12-05 23:03:48 +00:00
parent 1e15054e0e
commit df928764e2
5 changed files with 120 additions and 36 deletions

View File

@@ -5945,7 +5945,7 @@ code symbol description
------ ----------------------------------------- -----------------------------------------------------------------
81 packet_too_large The packet size exceeded the upper sanity check-limit
------ ----------------------------------------- -----------------------------------------------------------------
82 http_parse_error Failed to parse HTTP response
82 reserved
------ ----------------------------------------- -----------------------------------------------------------------
83 http_error The web server responded with an error
------ ----------------------------------------- -----------------------------------------------------------------
@@ -6006,15 +6006,15 @@ NAT-PMP errors:
====== ========================================= =================================================================
code symbol description
====== ========================================= =================================================================
108 unsupported_protocol_version The NAT-PMP router responded with an unsupported protocol version
120 unsupported_protocol_version The NAT-PMP router responded with an unsupported protocol version
------ ----------------------------------------- -----------------------------------------------------------------
109 natpmp_not_authorized You are not authorized to map ports on this NAT-PMP router
121 natpmp_not_authorized You are not authorized to map ports on this NAT-PMP router
------ ----------------------------------------- -----------------------------------------------------------------
110 network_failure The NAT-PMP router failed because of a network failure
122 network_failure The NAT-PMP router failed because of a network failure
------ ----------------------------------------- -----------------------------------------------------------------
111 no_resources The NAT-PMP router failed because of lack of resources
123 no_resources The NAT-PMP router failed because of lack of resources
------ ----------------------------------------- -----------------------------------------------------------------
112 unsupported_opcode The NAT-PMP router failed because an unsupported opcode was sent
124 unsupported_opcode The NAT-PMP router failed because an unsupported opcode was sent
====== ========================================= =================================================================
fastresume data errors:
@@ -6022,40 +6022,58 @@ fastresume data errors:
====== ========================================= =================================================================
code symbol description
====== ========================================= =================================================================
113 missing_file_sizes The resume data file is missing the 'file sizes' entry
130 missing_file_sizes The resume data file is missing the 'file sizes' entry
------ ----------------------------------------- -----------------------------------------------------------------
114 no_files_in_resume_data The resume data file 'file sizes' entry is empty
131 no_files_in_resume_data The resume data file 'file sizes' entry is empty
------ ----------------------------------------- -----------------------------------------------------------------
115 missing_pieces The resume data file is missing the 'pieces' and 'slots' entry
132 missing_pieces The resume data file is missing the 'pieces' and 'slots' entry
------ ----------------------------------------- -----------------------------------------------------------------
116 mismatching_number_of_files The number of files in the resume data does not match the number
133 mismatching_number_of_files The number of files in the resume data does not match the number
of files in the torrent
------ ----------------------------------------- -----------------------------------------------------------------
117 mismatching_files_size One of the files on disk has a different size than in the fast
134 mismatching_files_size One of the files on disk has a different size than in the fast
resume file
------ ----------------------------------------- -----------------------------------------------------------------
118 mismatching_file_timestamp One of the files on disk has a different timestamp than in the
135 mismatching_file_timestamp One of the files on disk has a different timestamp than in the
fast resume file
------ ----------------------------------------- -----------------------------------------------------------------
119 not_a_dictionary The resume data file is not a dictionary
136 not_a_dictionary The resume data file is not a dictionary
------ ----------------------------------------- -----------------------------------------------------------------
120 invalid_blocks_per_piece The 'blocks per piece' entry is invalid in the resume data file
137 invalid_blocks_per_piece The 'blocks per piece' entry is invalid in the resume data file
------ ----------------------------------------- -----------------------------------------------------------------
121 missing_slots The resume file is missing the 'slots' entry, which is required
138 missing_slots The resume file is missing the 'slots' entry, which is required
for torrents with compact allocation
------ ----------------------------------------- -----------------------------------------------------------------
122 too_many_slots The resume file contains more slots than the torrent
139 too_many_slots The resume file contains more slots than the torrent
------ ----------------------------------------- -----------------------------------------------------------------
123 invalid_slot_list The 'slot' entry is invalid in the resume data
140 invalid_slot_list The 'slot' entry is invalid in the resume data
------ ----------------------------------------- -----------------------------------------------------------------
124 invalid_piece_index One index in the 'slot' list is invalid
141 invalid_piece_index One index in the 'slot' list is invalid
------ ----------------------------------------- -----------------------------------------------------------------
125 pieces_need_reorder The pieces on disk needs to be re-ordered for the specified
142 pieces_need_reorder The pieces on disk needs to be re-ordered for the specified
allocation mode. This happens if you specify sparse allocation
and the files on disk are using compact storage. The pieces needs
to be moved to their right position
====== ========================================= =================================================================
HTTP errors:
====== ========================================= =================================================================
150 http_parse_error The HTTP header was not correctly formatted
------ ----------------------------------------- -----------------------------------------------------------------
151 http_missing_location The HTTP response was in the 300-399 range but lacked a location
header
------ ----------------------------------------- -----------------------------------------------------------------
152 http_failed_decompress The HTTP response was encoded with gzip or deflate but
decompressing it failed
====== ========================================= =================================================================
I2P errors:
====== ========================================= =================================================================
160 no_i2p_router The URL specified an i2p address, but no i2p router is configured
====== ========================================= =================================================================
The names of these error codes are declared in then ``libtorrent::errors`` namespace.
There is also another error category, ``libtorrent::upnp_category``, defining errors

View File

@@ -138,7 +138,7 @@ namespace libtorrent
duplicate_peer_id,
torrent_removed,
packet_too_large,
http_parse_error,
reserved82,
http_error,
missing_location,
invalid_redirection,
@@ -164,16 +164,33 @@ namespace libtorrent
pex_message_too_large,
invalid_pex_message,
invalid_lt_tracker_message,
reserved108,
reserved109,
reserved110,
reserved111,
reserved112,
reserved113,
reserved114,
reserved115,
reserved116,
reserved117,
reserved118,
reserved119,
// natpmp errors
unsupported_protocol_version,
unsupported_protocol_version, // 120
natpmp_not_authorized,
network_failure,
no_resources,
unsupported_opcode,
reserved125,
reserved126,
reserved127,
reserved128,
reserved129,
// fastresume errors
missing_file_sizes,
missing_file_sizes, // 130
no_files_in_resume_data,
missing_pieces,
mismatching_number_of_files,
@@ -186,16 +203,26 @@ namespace libtorrent
invalid_slot_list,
invalid_piece_index,
pieces_need_reorder,
reserved1,
reserved2,
reserved3,
reserved4,
reserved5,
reserved6,
reserved7,
reserved8,
no_i2p_router,
reserved143,
reserved144,
reserved145,
reserved146,
reserved147,
reserved148,
reserved149,
// HTTP errors
http_parse_error, // 150
http_missing_location,
http_failed_decompress,
reserved153,
reserved154,
reserved155,
reserved156,
reserved157,
reserved158,
reserved159,
// i2p errors
no_i2p_router, // 160
error_code_max
};

View File

@@ -130,7 +130,7 @@ namespace libtorrent
"duplicate peer-id",
"torrent removed",
"packet too large",
"failed to parse HTTP response",
"",
"HTTP error",
"missing location header",
"invalid redirection",
@@ -156,12 +156,29 @@ namespace libtorrent
"pex message too large",
"invalid pex message",
"invalid lt_tracker message",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
// natpmp errors
"unsupported protocol version",
"not authorized to create port map (enable NAT-PMP on your router)",
"network failure",
"out of resources",
"unsupported opcode",
"",
"",
"",
"",
"",
// fastresume errors
"missing or invalid 'file sizes' entry",
"no files in resume data",
@@ -183,7 +200,18 @@ namespace libtorrent
"",
"",
"",
// HTTP errors
"Invalid HTTP header",
"missing Location header in HTTP redirect",
"failed to decompress HTTP response",
"",
"",
"",
"",
"",
"",
"",
// i2p errors
"no i2p router is set up",
};
if (ev < 0 || ev >= sizeof(msgs)/sizeof(msgs[0]))

View File

@@ -489,7 +489,7 @@ void http_connection::callback(error_code const& e, char const* data, int size)
std::string error;
if (inflate_gzip(data, size, buf, max_bottled_buffer, error))
{
if (m_handler) m_handler(asio::error::fault, m_parser, data, size, *this);
if (m_handler) m_handler(errors::http_failed_decompress, m_parser, data, size, *this);
close();
return;
}
@@ -584,7 +584,7 @@ void http_connection::on_read(error_code const& e
if (error)
{
// HTTP parse error
error_code ec = asio::error::fault;
error_code ec = errors::http_parse_error;
callback(ec, 0, 0);
return;
}
@@ -601,7 +601,7 @@ void http_connection::on_read(error_code const& e
if (location.empty())
{
// missing location header
callback(asio::error::fault);
callback(error_code(errors::http_missing_location));
close();
return;
}

View File

@@ -371,6 +371,17 @@ int test_main()
error_code ec;
int ret = 0;
TEST_CHECK(error_code(errors::http_error).message() == "HTTP error");
TEST_CHECK(error_code(errors::missing_file_sizes).message() == "missing or invalid 'file sizes' entry");
TEST_CHECK(error_code(errors::unsupported_protocol_version).message() == "unsupported protocol version");
TEST_CHECK(error_code(errors::no_i2p_router).message() == "no i2p router is set up");
TEST_CHECK(error_code(errors::http_parse_error).message() == "Invalid HTTP header");
TEST_CHECK(error_code(errors::error_code_max).message() == "Unknown error");
TEST_CHECK(errors::reserved129 == 129);
TEST_CHECK(errors::reserved159 == 159);
TEST_CHECK(errors::reserved108 == 108);
{
// test session state load/restore
session* s = new session(fingerprint("LT",0,0,0,0), 0);