Skip to content

Commit 36f4e29

Browse files
committed
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.
1 parent bd0b338 commit 36f4e29

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/libstore/filetransfer.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,23 @@ struct curlFileTransfer : public FileTransfer
151151
}
152152
}
153153

154-
void failEx(std::exception_ptr ex)
154+
void failEx(std::exception_ptr ex) noexcept
155155
{
156156
assert(!done);
157157
done = true;
158+
try {
159+
std::rethrow_exception(ex);
160+
} catch (nix::Error & e) {
161+
/* Add more context to the error message. */
162+
e.addTrace({}, "during %s of '%s'", Uncolored(request.verb()), request.uri.to_string());
163+
} catch (...) {
164+
/* Can't add more context to the error. */
165+
}
158166
callback.rethrow(ex);
159167
}
160168

161169
template<class T>
162-
void fail(T && e)
170+
void fail(T && e) noexcept
163171
{
164172
failEx(std::make_exception_ptr(std::forward<T>(e)));
165173
}

0 commit comments

Comments
 (0)