[ 
https://issues.apache.org/jira/browse/THRIFT-727?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14518231#comment-14518231
 ] 

ASF GitHub Bot commented on THRIFT-727:
---------------------------------------

GitHub user mreve opened a pull request:

    https://github.com/apache/thrift/pull/469

    Thrift 727 - support C++ native exception message

    Added code generating implementation of std::exception::what() function for 
exceptions.
    
    I needed to modify the tutorial's IDL file, as well as CppClient and 
CppServer files, because member field of the exception defined & used there is 
named "what", and that made the compiler complain.
    
    The modification in CppClient contains only a comment - it can be 
uncommented and used as a test, to see the result of my change.
    
    Please view the discussion in Jira:
    https://issues.apache.org/jira/browse/THRIFT-727

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/mreve/thrift THRIFT-727

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/thrift/pull/469.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #469
    
----
commit 8ca78b09e4540cd89f87bbb6ecd9854e5e5d4acd
Author: mreve <[email protected]>
Date:   2015-04-28T21:54:37Z

    Change InvalidOperation field "what" to "what_op"
    
    Because it can't coexist with generated method what().

commit 5cfd3c82095f8499f87c17a245e6d06a6d7d77ac
Author: mreve <[email protected]>
Date:   2015-04-28T21:57:24Z

    Update CppClient.cpp
    
    Added a comment that suggests using cpp-native std::exception::what() 
method to obtain information about an error.

commit e49f5ce883e879e6796f8992c6550eaa33fef298
Author: mreve <[email protected]>
Date:   2015-04-28T21:59:29Z

    Use the right InvalidOperation member field name
    
    Change from "what" to "what_op" as what is now a function.

commit 73f8240b65a5eebd8ee54ef5df2e08325ee98361
Author: mreve <[email protected]>
Date:   2015-04-28T22:09:44Z

    Generate std::exception::what() implementation for exceptions

commit 160528fb5db2388aaec8b0efede6023be12dd41c
Author: mreve <[email protected]>
Date:   2015-04-28T22:17:50Z

    Fix the typo

----


> support native language specific exception message
> --------------------------------------------------
>
>                 Key: THRIFT-727
>                 URL: https://issues.apache.org/jira/browse/THRIFT-727
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.2
>         Environment: all
>            Reporter: Ping Li
>            Priority: Minor
>
> The current exception implement requires the error message to be declared and 
> referenced explicitly, especially when it's sent from server to the client. 
> On client side, this error message cannot be accessed via a native API like 
> exception::what() in C++.
> Example,
> {code}
> exception MyException {
>   1: i32   code;
>   2: string message;
> }
> {code}
> On client side, it can only be accessed like this,
> {code}
> try {
>   server->someMethod();
> } catch (MyException &e) {
>   cout << "MyException: " << e.message << endl;     // this will print the 
> exception message
>   cout << "MyException: " << e.what() << endl;      // this will print 
> TException::Default
> }
> {code}
> At the same time, if TException::message_ is initialized, exception::what() 
> does work when the exception is caught locally.
> It's a little confusing when to use the native method, and when to use Thrift 
> exception message data member.
> It'll be really nice if all exception messages can be accessed the same way 
> thru the navtive language on client side.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to