1
1
Fork 0
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:
Sergei Zimmerman 2025-11-19 02:22:23 +03:00
parent bd0b338e15
commit 36f4e290d0
No known key found for this signature in database

View file

@ -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)));
} }