libtorrent version (or branch):
RC_1_2
please describe what symptom you see, what you would expect to see instead and
how to reproduce it.
Suppose I have a const lt::tracker_error_alert *p.
If I do p->message(), that gives me all the information (torrent name, tracker url, endpoint, error message and times_in_row).
It is possible to reconstruct p->message() using the various other fields. But p->error_message() is often empty. I guess it is supposed to be the same as p->error.message(), but this is not always the case.
Is this expected? Am I supposed to prefer p->error.message() over p->error_message()?
error_message() contains the tracker response key "failure reason", which isn't necessarily present. There may be failures where there is no response for instance, like time-out, connection refused, etc. There seem to be some cases where I pass along additional information as a string though, that isn't coming from the tracker. Maybe that's not so good.
But, I would say, the error_code ("error") is the fundamental error, and sometimes the string message may provide additional details about it.
@arvidn
I see. Then I believe my confusion comes from the fact that p->error.message() will contain _any_ error message, whether it is network-related (e.g. Host not found (non-authoritative)) or a "failure reason" sent by the tracker, while error_message() only contains the latter, and is empty in the case of the former, for which there is no analogue.
I guess I wasn't really expecting that. Perhaps error_message() should have a better name like failure_reason()? error_message() makes it seem like it contains information from _any_ error. Or perhaps the documentation should simply clarify that error_message() is simply for reporting "failure reasons", and that to really check for _any_ error when announcing to a tracker, including networking, the user should use error.message() (I noticed the current docs also mention the deprecated status_code). What do you think?
Then I believe my confusion comes from the fact that p->error.message() will contain any error message
It's not a superset. If the tracker fails "gracefully", i.e. it sends a "failure reason" message, the error will just say "tracker error".
error_code is really just an integer, like errno, and calling message() on it is like calling strerror() on an error code.
I guess I wasn't really expecting that. Perhaps error_message() should have a better name like failure_reason()?
I agree.
@FranciscoPombal how does this look? https://github.com/arvidn/libtorrent/pull/4822
I think this has been addressed now