added torrent_error_alert when a torrent encounters an error

This commit is contained in:
Arvid Norberg 2011-01-22 19:06:43 +00:00
parent 483870cd83
commit 1dc0e71716
4 changed files with 42 additions and 0 deletions

View File

@ -6024,6 +6024,21 @@ generated and the torrent is paused.
error_code error;
};
torrent_error_alert
-------------------
This is posted whenever a torrent is transitioned into the error state.
::
struct torrent_error_alert: torrent_alert
{
// ...
error_code error;
};
The ``error`` specifies which error the torrent encountered.
file_renamed_alert
------------------

View File

@ -1216,6 +1216,22 @@ namespace libtorrent
error_code error;
};
struct TORRENT_EXPORT torrent_error_alert: torrent_alert
{
torrent_error_alert(torrent_handle const& h
, error_code const& e)
: torrent_alert(h)
, error(e)
{}
TORRENT_DEFINE_ALERT(torrent_error_alert);
const static int static_category = alert::error_notification | alert::status_notification;
virtual std::string message() const;
error_code error;
};
}

View File

@ -505,5 +505,13 @@ namespace libtorrent {
return msg;
}
std::string torrent_error_alert::message() const
{
char msg[200];
snprintf(msg, sizeof(msg), " ERROR: %s", error.message().c_str());
return torrent_alert::message() + msg;
}
} // namespace libtorrent

View File

@ -5770,6 +5770,9 @@ namespace libtorrent
m_error = ec;
m_error_file = error_file;
if (alerts().should_post<torrent_error_alert>())
alerts().post_alert(torrent_error_alert(get_handle(), ec));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING || defined TORRENT_LOGGING
if (ec)
{