public async ValueTask <Exception?> SetFailed(Exception?unhandledException, bool sendCancel, bool async) { if (IsDisposed) { return(null); } Exception?processedException = null; if (sendCancel) { try { await SendCancel(async); } catch (Exception ex) { var networkException = new ClickHouseException(ClickHouseErrorCodes.NetworkError, "Network error. Operation was not canceled properly.", ex); processedException = unhandledException != null ? (Exception) new AggregateException(unhandledException, networkException) : networkException; } } _client.SetFailed(unhandledException); return(processedException); }