Skip to content

Commit 63ef2ce

Browse files
committed
Throw exceptions for subscribe/unsubscribe errors
1 parent 6afddc4 commit 63ef2ce

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

samples/today/TodayMock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ class NextAppointmentChange
547547

548548
std::shared_ptr<object::Node> getNodeChange(const response::IdType&) const
549549
{
550-
throw std::runtime_error("Unexpected call to getNodeChange");
550+
return {};
551551
}
552552

553553
private:

src/GraphQLService.cpp

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,10 +1850,17 @@ AwaitableSubscribe Request::subscribe(RequestSubscribeParams params)
18501850
try
18511851
{
18521852
co_await launch;
1853-
co_await operation->resolve(selectionSetParams,
1854-
registration->selection,
1855-
registration->data->fragments,
1856-
registration->data->variables);
1853+
1854+
auto errors = std::move((co_await operation->resolve(selectionSetParams,
1855+
registration->selection,
1856+
registration->data->fragments,
1857+
registration->data->variables))
1858+
.errors);
1859+
1860+
if (!errors.empty())
1861+
{
1862+
throw schema_exception { std::move(errors) };
1863+
}
18571864
}
18581865
catch (const std::exception& ex)
18591866
{
@@ -1873,6 +1880,7 @@ AwaitableUnsubscribe Request::unsubscribe(RequestUnsubscribeParams params)
18731880
const auto spThis = shared_from_this();
18741881
std::unique_lock lock { spThis->_subscriptionMutex };
18751882
const auto itrOperation = spThis->_operations.find(strSubscription);
1883+
std::list<schema_error> errors {};
18761884

18771885
if (itrOperation != spThis->_operations.end())
18781886
{
@@ -1892,16 +1900,22 @@ AwaitableUnsubscribe Request::unsubscribe(RequestUnsubscribeParams params)
18921900
lock.unlock();
18931901

18941902
co_await params.launch;
1895-
co_await operation->resolve(selectionSetParams,
1896-
registration->selection,
1897-
registration->data->fragments,
1898-
registration->data->variables);
1903+
errors = std::move((co_await operation->resolve(selectionSetParams,
1904+
registration->selection,
1905+
registration->data->fragments,
1906+
registration->data->variables))
1907+
.errors);
18991908

19001909
lock.lock();
19011910
}
19021911

19031912
spThis->removeSubscription(params.key);
19041913

1914+
if (!errors.empty())
1915+
{
1916+
throw schema_exception { std::move(errors) };
1917+
}
1918+
19051919
co_return;
19061920
}
19071921

0 commit comments

Comments
 (0)