34
34
#define TORRENT_ERROR_CODE_HPP_INCLUDED
36
36
#include <boost/version.hpp>
37
#include <boost/shared_ptr.hpp>
39
#if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN
40
// asio assumes that the windows error codes are defined already
38
44
#if BOOST_VERSION < 103500
39
45
#include <asio/error_code.hpp>
53
57
enum error_code_enum
65
torrent_missing_piece_length,
68
torrent_invalid_length,
69
torrent_file_parse_failed,
70
torrent_missing_pieces,
71
torrent_invalid_hashes,
72
too_many_pieces_in_torrent,
73
invalid_swarm_metadata,
76
invalid_escaped_string,
79
invalid_torrent_handle,
81
missing_info_hash_in_uri,
83
unsupported_url_protocol,
85
peer_sent_empty_piece,
89
mismatching_info_hash,
93
expected_close_bracket_in_address,
96
upload_upload_connection,
97
uninteresting_upload_peer,
101
invalid_bitfield_size,
102
too_many_requests_when_choked,
108
timed_out_no_interest,
109
timed_out_inactivity,
110
timed_out_no_handshake,
111
timed_out_no_request,
115
invalid_not_interested,
129
invalid_encryption_constant,
132
unsupported_encryption_mode,
133
unsupported_encryption_mode_selected,
135
invalid_encrypt_handshake,
136
no_incoming_encrypted,
149
too_many_connections,
152
too_many_corrupt_pieces,
154
peer_not_constructed,
156
optimistic_disconnect,
160
invalid_metadata_request,
161
invalid_metadata_size,
162
invalid_metadata_offset,
163
invalid_metadata_message,
164
pex_message_too_large,
166
invalid_lt_tracker_message,
181
unsupported_protocol_version, // 120
182
natpmp_not_authorized,
193
missing_file_sizes, // 130
194
no_files_in_resume_data,
196
mismatching_number_of_files,
197
mismatching_file_size,
198
mismatching_file_timestamp,
200
invalid_blocks_per_piece,
214
http_parse_error, // 150
215
http_missing_location,
216
http_failed_decompress,
230
#if BOOST_VERSION >= 103500
232
namespace boost { namespace system {
234
template<> struct is_error_code_enum<libtorrent::errors::error_code_enum>
235
{ static const bool value = true; };
237
template<> struct is_error_condition_enum<libtorrent::errors::error_code_enum>
238
{ static const bool value = true; };
60
246
#if BOOST_VERSION < 103500
61
247
typedef asio::error_code error_code;
62
248
inline asio::error::error_category get_posix_category() { return asio::error::system_category; }
63
249
inline asio::error::error_category get_system_category() { return asio::error::system_category; }
251
boost::system::error_category const& get_libtorrent_category()
253
static ::asio::error::error_category libtorrent_category(20);
254
return libtorrent_category;
66
struct libtorrent_error_category : boost::system::error_category
259
struct TORRENT_EXPORT libtorrent_error_category : boost::system::error_category
68
261
virtual const char* name() const;
69
262
virtual std::string message(int ev) const;
71
264
{ return boost::system::error_condition(ev, *this); }
74
extern libtorrent_error_category libtorrent_category;
267
inline boost::system::error_category& get_libtorrent_category()
269
static libtorrent_error_category libtorrent_category;
270
return libtorrent_category;
275
inline boost::system::error_code make_error_code(error_code_enum e)
277
return boost::system::error_code(e, get_libtorrent_category());
76
281
using boost::system::error_code;
77
282
inline boost::system::error_category const& get_system_category()
81
286
{ return boost::system::get_posix_category(); }
83
288
{ return boost::system::get_generic_category(); }
289
#endif // BOOST_VERSION < 103600
290
#endif // BOOST_VERSION < 103500
87
292
#ifndef BOOST_NO_EXCEPTIONS
88
293
struct TORRENT_EXPORT libtorrent_exception: std::exception