You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "James E. King, III (JIRA)" <ji...@apache.org> on 2015/06/22 20:30:02 UTC

[jira] [Comment Edited] (THRIFT-727) support native C++ language specific exception message

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

James E. King, III edited comment on THRIFT-727 at 6/22/15 6:29 PM:
--------------------------------------------------------------------

Note that this may end up being a breaking change for some folks.  In one project I observed that an exception was declared with a {{1:string what;}} and after upgrading to a build with this code in it the generated code failed to compile due to the conflict with this change.  I believe the correct resolution for that is to remove the what definition from the IDL and just let the standard exception constructor that takes a std::string handle it, however that may cause some code changes to handle.

The only recourse then is to go back and change the IDL to use another keyword for the string, however that breaks backwards compatibility on all existing clients in the field, which is really awful.


was (Author: jking3):
Note that this may end up being a breaking change for some folks.  In one project I observed that an exception was declared with a {{1:string what;}} and after upgrading to a build with this code in it the generated code failed to compile due to the conflict with this change.  I believe the correct resolution for that is to remove the what definition from the IDL and just let the standard exception constructor that takes a std::string handle it, however that may cause some code changes to handle.

> support native C++ language specific exception message
> ------------------------------------------------------
>
>                 Key: THRIFT-727
>                 URL: https://issues.apache.org/jira/browse/THRIFT-727
>             Project: Thrift
>          Issue Type: Improvement
>          Components: C++ - Compiler
>    Affects Versions: 0.2
>         Environment: all
>            Reporter: Ping Li
>            Assignee: Anna Dymek
>            Priority: Minor
>             Fix For: 0.9.3
>
>         Attachments: THRIFT-727-AddOn-Fix-GoTutorial-broken.patch
>
>
> 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)