mirror of
https://github.com/NixOS/nix.git
synced 2025-11-22 02:09:36 +01:00
libstore/filetransfer: Add more context to error message
Now the error message looks something like:
error:
… during upload of 'file:///tmp/storeabc/4yxrw9flcvca7f3fs7c5igl2ica39zaw.narinfo'
error: blah blah
Also makes fail and failEx themselves noexcept, since all the operations they
do are noexcept and we don't want exceptions escaping from them.
This commit is contained in:
parent
bd0b338e15
commit
36f4e290d0
1 changed files with 10 additions and 2 deletions
|
|
@ -151,15 +151,23 @@ struct curlFileTransfer : public FileTransfer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void failEx(std::exception_ptr ex)
|
void failEx(std::exception_ptr ex) noexcept
|
||||||
{
|
{
|
||||||
assert(!done);
|
assert(!done);
|
||||||
done = true;
|
done = true;
|
||||||
|
try {
|
||||||
|
std::rethrow_exception(ex);
|
||||||
|
} catch (nix::Error & e) {
|
||||||
|
/* Add more context to the error message. */
|
||||||
|
e.addTrace({}, "during %s of '%s'", Uncolored(request.verb()), request.uri.to_string());
|
||||||
|
} catch (...) {
|
||||||
|
/* Can't add more context to the error. */
|
||||||
|
}
|
||||||
callback.rethrow(ex);
|
callback.rethrow(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void fail(T && e)
|
void fail(T && e) noexcept
|
||||||
{
|
{
|
||||||
failEx(std::make_exception_ptr(std::forward<T>(e)));
|
failEx(std::make_exception_ptr(std::forward<T>(e)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue