Skip to content

Commit cf9c2c0

Browse files
committed
Adding catch handler in ws_winrt.cpp back to avoid slicing and losing exception type information.
1 parent b3a30ce commit cf9c2c0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Release/src/websockets/client/ws_winrt.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,16 @@ class winrt_client : public _websocket_client_impl, public std::enable_shared_fr
345345
eptr = std::make_exception_ptr(websocket_exception("Failed to send all the bytes."));
346346
}
347347
}
348+
catch (Platform::Exception^ e)
349+
{
350+
// Convert to websocket_exception.
351+
eptr = std::make_exception_ptr(websocket_exception(e->HResult));
352+
}
353+
catch (const websocket_exception &e)
354+
{
355+
// Catch to avoid slicing and losing the type if falling through to catch (...).
356+
eptr = std::make_exception_ptr(e);
357+
}
348358
catch (...)
349359
{
350360
eptr = std::make_exception_ptr(std::current_exception());

0 commit comments

Comments
 (0)