[
https://issues.apache.org/jira/browse/THRIFT-727?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14536493#comment-14536493
]
Konrad Grochowski commented on THRIFT-727:
------------------------------------------
Unfortunately we can't fill it in constructor as fields in struct can change.
Maybe we should resign from including fields values in what message in favor of
noexcept safety and just returning const char with exception name.
-------- Oryginalna wiadomość --------
Od: "James E. King, III (JIRA)" <[email protected]>
Data:09.05.2015 13:54 (GMT+01:00)
Do: [email protected]
Temat: [jira] [Commented] (THRIFT-727) support native language specific
exception message
James E. King, III commented on THRIFT-727
Re: support native language specific exception message
A unit test needs to be added for the new functionality, and what() needs to
change so it does not call any code that can throw an exception which means no
std::stringstream and no std::string (unless exception handling is used) -
better to allocate a buffer in the exception constructor and fill it in, then
return the buffer pointer in the body of what().
Add Comment
This message was sent by Atlassian JIRA (v6.3.4#6332-sha1:51bc225)
> 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)