Skip to content

Commit cba551a

Browse files
yfeldblumfacebook-github-bot
authored andcommitted
exception_wrapper thrown variant via abi/runtime
Summary: Reimplement `folly::exception_wrapper` thrown variant not to need to cache any pointers and rather to access the exception object and runtime type, and to perform runtime upcasting, via the platform runtime. This both simplifies and extends the capability of the thrown variant. Reviewed By: JunqiWang Differential Revision: D28625444 fbshipit-source-id: 12409bc75794f5135cdb73563b07fafdf5cc44cd
1 parent 9555348 commit cba551a

File tree

2 files changed

+2
-22
lines changed

2 files changed

+2
-22
lines changed

Diff for: rsocket/test/transport/TcpDuplexConnectionTest.cpp

-20
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,5 @@ TEST(TcpDuplexConnection, ConnectionAndSubscribersAreUntied) {
109109
worker.getEventBase());
110110
}
111111

112-
TEST(TcpDuplexConnection, ExceptionWrapperTest) {
113-
folly::AsyncSocketException socketException(
114-
folly::AsyncSocketException::AsyncSocketExceptionType::INVALID_STATE,
115-
"test",
116-
10);
117-
folly::SSLException sslException(5, 10, 15, 20);
118-
119-
const folly::AsyncSocketException& socketExceptionRef = sslException;
120-
121-
folly::exception_wrapper ex1(socketException);
122-
folly::exception_wrapper ex2(sslException);
123-
124-
// Slicing error:
125-
// folly::exception_wrapper ex3(socketExceptionRef);
126-
127-
// Fixed version:
128-
folly::exception_wrapper ex3(
129-
std::make_exception_ptr(socketExceptionRef), socketExceptionRef);
130-
}
131-
132112
} // namespace tests
133113
} // namespace rsocket

Diff for: rsocket/transports/tcp/TcpDuplexConnection.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class TcpReaderWriter : public folly::AsyncTransportWrapper::WriteCallback,
109109

110110
void writeErr(size_t, const folly::AsyncSocketException& exn) noexcept
111111
override {
112-
closeErr(folly::exception_wrapper{std::make_exception_ptr(exn), exn});
112+
closeErr(folly::exception_wrapper{folly::copy(exn)});
113113
intrusive_ptr_release(this);
114114
}
115115

@@ -134,7 +134,7 @@ class TcpReaderWriter : public folly::AsyncTransportWrapper::WriteCallback,
134134
}
135135

136136
void readErr(const folly::AsyncSocketException& exn) noexcept override {
137-
closeErr(folly::exception_wrapper{std::make_exception_ptr(exn), exn});
137+
closeErr(folly::exception_wrapper{folly::copy(exn)});
138138
intrusive_ptr_release(this);
139139
}
140140

0 commit comments

Comments
 (0)