Commit 6da8593f authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Saner test exception in ExceptionWrapperTest.cpp

Summary:
[Folly] Saner test exception in `ExceptionWrapperTest.cpp`.

Make construction do the work and make `what()` free.

Reviewed By: andrewjcg

Differential Revision: D5216707

fbshipit-source-id: bfb4c2473a61ff7da7a3a01adc85facae30d6586
parent d3e8b83f
...@@ -29,17 +29,16 @@ class AbstractIntException : public std::exception { ...@@ -29,17 +29,16 @@ class AbstractIntException : public std::exception {
class IntException : public AbstractIntException { class IntException : public AbstractIntException {
public: public:
explicit IntException(int i) : i_(i) {} explicit IntException(int i) : i_(i), what_(to<std::string>("int == ", i_)) {}
int getInt() const override { return i_; } int getInt() const override { return i_; }
const char* what() const noexcept override { const char* what() const noexcept override {
what_ = folly::to<std::string>("int == ", i_);
return what_.c_str(); return what_.c_str();
} }
private: private:
int i_; int i_;
mutable std::string what_; std::string what_;
}; };
const static std::string kExceptionClassName = const static std::string kExceptionClassName =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment