Make copy_to raise exceptions from the writer thread.
Otherwise exceptions are silently ignored, until the transaction finishes. And when the transaction fails, the returned error message is unhelpful.
This commit makes copy_to return the actual error message.
Migrated from D1872 (view on Phabricator)