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

Yuxuan Wang commented on THRIFT-5823:
-------------------------------------

{quote}but expected that exceptions and structs are different beasts in most 
(if not all) languages{quote}

My reading from the part of the whitepaper you quoted is different. My reading 
is that it would work the same/similarly to a struct, with the addition that 
the type can be throw/catch in the language. In languages like java, python, 
go, etc., it's trivial (and currently implemented so) to make exceptions that 
both implements TStruct and the language's exception base class, through 
multiple inheritance or other means.

Re your PS: not every operation needs to be idempotent. Use batch operation 
(idempotent or not) to save multiple round trips is a common practice, and 
batch operations can have partial failures (again, idempotent or not), for 
example:

{code:}
struct GetRequest {
  1: string id;
  ...
}

struct GetResponse {
  ...
}

struct BatchGetRequest {
  1: list<GetRequest> requests
}

struct BatchGetResponse {
  1: map<string, GetRequest> responses,  // key is id
  2: map<string, SomeErrorDetail> errors,  // key is id
}

service Foo {
  GetResponse get(1: GetRequest request) throws(1: SomeException error);
  BatchGetResponse batchGet(1: BatchGetRequest request) throws(1: SomeException 
error); // may or may not be the same exception type, only throw exception when 
full request failed
}
{code}

For money moving requests, you would have the same idempotentation issue with 
full failures, partial failures does not change that.

> Fix illegal uses of exceptions as normal struct type
> ----------------------------------------------------
>
>                 Key: THRIFT-5823
>                 URL: https://issues.apache.org/jira/browse/THRIFT-5823
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (General)
>            Reporter: Jens Geyer
>            Assignee: Jens Geyer
>            Priority: Major
>             Fix For: 0.22.0
>
>         Attachments: THRIFT-5823.thrift
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> Fix illegal uses of exvceptions as normal struct type, which it really isn't. 
> Applies to a number of test IDL files and various tickets.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to