improve error reporting of lazy_bdecode to use error_code
This commit is contained in:
@@ -842,7 +842,8 @@ int main(int argc, char* argv[])
|
||||
if (load_file(".ses_state", in) == 0)
|
||||
{
|
||||
lazy_entry e;
|
||||
if (lazy_bdecode(&in[0], &in[0] + in.size(), e) == 0)
|
||||
error_code ec;
|
||||
if (lazy_bdecode(&in[0], &in[0] + in.size(), e, ec) == 0)
|
||||
ses.load_state(e);
|
||||
}
|
||||
|
||||
|
@@ -60,17 +60,18 @@ int main(int argc, char* argv[])
|
||||
return 1;
|
||||
}
|
||||
lazy_entry e;
|
||||
ret = lazy_bdecode(&buf[0], &buf[0] + buf.size(), e);
|
||||
error_code ec;
|
||||
int pos;
|
||||
ret = lazy_bdecode(&buf[0], &buf[0] + buf.size(), e, ec, &pos);
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
fprintf(stderr, "invalid bencoding: %d\n", ret);
|
||||
fprintf(stderr, "failed to decode: '%s' at character: %d\n", ec.message().c_str(), pos);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("\n\n----- raw info -----\n\n%s\n", print_entry(e).c_str());
|
||||
|
||||
error_code ec;
|
||||
torrent_info t(e, ec);
|
||||
if (ec)
|
||||
{
|
||||
|
Reference in New Issue
Block a user