diff options
author | Konrad Grochowski <hcorg@apache.org> | 2015-05-18 17:58:36 +0200 |
---|---|---|
committer | Konrad Grochowski <hcorg@apache.org> | 2015-05-18 19:47:23 +0200 |
commit | 3b115dfa614cfac7af86d81d99f69b381508b75e (patch) | |
tree | 525eef0ea64f6e3065ab416599c1be2b8be9e6a7 /tutorial/cpp | |
parent | 83cd3e8d41001304f2efac9ebad92e02d3390ca7 (diff) | |
download | thrift-3b115dfa614cfac7af86d81d99f69b381508b75e.tar.gz |
THRIFT-727 - C++: what() method of generated exceptions will provide more information
Patch: Anna Dymek <aadymek@gmail.com>
Client: C++
This closes #469
Diffstat (limited to 'tutorial/cpp')
-rw-r--r-- | tutorial/cpp/CppClient.cpp | 1 | ||||
-rw-r--r-- | tutorial/cpp/CppServer.cpp | 4 |
2 files changed, 3 insertions, 2 deletions
diff --git a/tutorial/cpp/CppClient.cpp b/tutorial/cpp/CppClient.cpp index 258cbd66d..2763fee5e 100644 --- a/tutorial/cpp/CppClient.cpp +++ b/tutorial/cpp/CppClient.cpp @@ -58,6 +58,7 @@ int main() { } catch (InvalidOperation& io) { cout << "InvalidOperation: " << io.why << endl; // or using generated operator<<: cout << io << endl; + // or by using std::exception native method what(): cout << io.what() << endl; } work.op = Operation::SUBTRACT; diff --git a/tutorial/cpp/CppServer.cpp b/tutorial/cpp/CppServer.cpp index 84b79d420..6b22193a4 100644 --- a/tutorial/cpp/CppServer.cpp +++ b/tutorial/cpp/CppServer.cpp @@ -71,7 +71,7 @@ public: case Operation::DIVIDE: if (work.num2 == 0) { InvalidOperation io; - io.what = work.op; + io.whatOp = work.op; io.why = "Cannot divide by 0"; throw io; } @@ -79,7 +79,7 @@ public: break; default: InvalidOperation io; - io.what = work.op; + io.whatOp = work.op; io.why = "Invalid Operation"; throw io; } |