{"action":"created","issue":{"url":"https://api.github.com/repos/maximg/thrift/issues/14","labels_url":"https://api.github.com/repos/maximg/thrift/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/maximg/thrift/issues/14/comments","events_url":"https://api.github.com/repos/maximg/thrift/issues/14/events","html_url":"https://github.com/maximg/thrift/issues/14","id":55543353,"number":14,"title":"Support thrift exceptions","user":{"login":"maximg","id":957609,"avatar_url":"https://avatars.githubusercontent.com/u/957609?v=3","gravatar_id":"","url":"https://api.github.com/users/maximg","html_url":"https://github.com/maximg","followers_url":"https://api.github.com/users/maximg/followers","following_url":"https://api.github.com/users/maximg/following{/other_user}","gists_url":"https://api.github.com/users/maximg/gists{/gist_id}","starred_url":"https://api.github.com/users/maximg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maximg/subscriptions","organizations_url":"https://api.github.com/users/maximg/orgs","repos_url":"https://api.github.com/users/maximg/repos","events_url":"https://api.github.com/users/maximg/events{/privacy}","received_events_url":"https://api.github.com/users/maximg/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/maximg/thrift/labels/help%20wanted","name":"help wanted","color":"159818"}],"state":"open","locked":false,"assignee":{"login":"gsingh93","id":1012677,"avatar_url":"https://avatars.githubusercontent.com/u/1012677?v=3","gravatar_id":"","url":"https://api.github.com/users/gsingh93","html_url":"https://github.com/gsingh93","followers_url":"https://api.github.com/users/gsingh93/followers","following_url":"https://api.github.com/users/gsingh93/following{/other_user}","gists_url":"https://api.github.com/users/gsingh93/gists{/gist_id}","starred_url":"https://api.github.com/users/gsingh93/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gsingh93/subscriptions","organizations_url":"https://api.github.com/users/gsingh93/orgs","repos_url":"https://api.github.com/users/gsingh93/repos","events_url":"https://api.github.com/users/gsingh93/events{/privacy}","received_events_url":"https://api.github.com/users/gsingh93/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/maximg/thrift/milestones/1","html_url":"https://github.com/maximg/thrift/milestones/client_to_main","labels_url":"https://api.github.com/repos/maximg/thrift/milestones/1/labels","id":1141752,"number":1,"title":"client_to_main","description":null,"creator":{"login":"maximg","id":957609,"avatar_url":"https://avatars.githubusercontent.com/u/957609?v=3","gravatar_id":"","url":"https://api.github.com/users/maximg","html_url":"https://github.com/maximg","followers_url":"https://api.github.com/users/maximg/followers","following_url":"https://api.github.com/users/maximg/following{/other_user}","gists_url":"https://api.github.com/users/maximg/gists{/gist_id}","starred_url":"https://api.github.com/users/maximg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maximg/subscriptions","organizations_url":"https://api.github.com/users/maximg/orgs","repos_url":"https://api.github.com/users/maximg/repos","events_url":"https://api.github.com/users/maximg/events{/privacy}","received_events_url":"https://api.github.com/users/maximg/received_events","type":"User","site_admin":false},"open_issues":8,"closed_issues":2,"state":"open","created_at":"2015-05-31T16:05:48Z","updated_at":"2015-06-06T17:12:33Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2015-01-26T21:55:46Z","updated_at":"2015-06-06T17:22:43Z","closed_at":null,"body":"We need to receive Thrift exceptions and pass them on to the caller as an Err(...). A possible approach is here: http://is.gd/9Ju5q2"},"comment":{"url":"https://api.github.com/repos/maximg/thrift/issues/comments/109620241","html_url":"https://github.com/maximg/thrift/issues/14#issuecomment-109620241","issue_url":"https://api.github.com/repos/maximg/thrift/issues/14","id":109620241,"user":{"login":"maximg","id":957609,"avatar_url":"https://avatars.githubusercontent.com/u/957609?v=3","gravatar_id":"","url":"https://api.github.com/users/maximg","html_url":"https://github.com/maximg","followers_url":"https://api.github.com/users/maximg/followers","following_url":"https://api.github.com/users/maximg/following{/other_user}","gists_url":"https://api.github.com/users/maximg/gists{/gist_id}","starred_url":"https://api.github.com/users/maximg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maximg/subscriptions","organizations_url":"https://api.github.com/users/maximg/orgs","repos_url":"https://api.github.com/users/maximg/repos","events_url":"https://api.github.com/users/maximg/events{/privacy}","received_events_url":"https://api.github.com/users/maximg/received_events","type":"User","site_admin":false},"created_at":"2015-06-06T17:22:43Z","updated_at":"2015-06-06T17:22:43Z","body":"Here is the email trace of the discussion we had on this so far:\r\n\r\nFrom: Simon Génier \r\nDate: Sun, Feb 1, 2015 at 6:08 PM\r\nSubject: Re: rust-thrift: exceptions\r\nTo: Maxim Golov \r\n\r\nThe problem with TResult is that the set of exception is different for each method and AFAIK there are no variadic type parameters in Rust.\r\n\r\n\r\nOn Mon Jan 26 2015 at 2:36:43 AM Maxim Golov wrote:\r\nOne thing we could try to get rid of when adding the exceptions is ProtocolHelpers::receive, I suspect it can be consolidated with \"impl Readable\" for each struct; also if we pass exceptions through TResult we may drop the need for the ServiceFunctionResult structure altogether.\r\n\r\nOn Sat, Jan 24, 2015 at 7:02 PM, Simon Génier wrote:\r\nYes, this would work. The upside Is see as opposed to having a flat enum is that there are a lot of functions in the standard lib for working with Result<T>, so the \"happy path\" where the request is successful will be very easy to consume. The downside is that you have two levels of enum, but I don't think this is an issue.\r\n\r\nI'd suggest we go with Result<T> like you suggested and see how it goes.\r\n\r\nSimon\r\n\r\nOn Fri Jan 23 2015 at 3:38:34 PM Maxim Golov wrote:\r\nDo you think this approach can help us in any way?\r\n\r\nhttp://is.gd/9Ju5q2\r\n\r\n```\r\nstruct BadCastException;\r\nstruct OverflowException;\r\n\r\n// generated\r\n#[allow(dead_code)]\r\nenum CalcException {\r\n  BadCast(BadCastException),\r\n  Overflow(OverflowException),\r\n  // more\r\n}\r\n\r\n#[allow(dead_code)]\r\nenum MyResult<T> {\r\n  Success,\r\n  Error(T)\r\n}\r\n\r\nfn calc() -> MyResult<CalcException> {\r\n  MyResult::Error(CalcException::BadCast(BadCastException))\r\n}\r\n\r\nfn main() {\r\n  println!(\"Result: {}\", match calc() {\r\n    MyResult::Success => \"Ok\",\r\n    MyResult::Error(_) => \"Error\",\r\n  });\r\n}\r\n```\r\nOn Fri, Jan 23, 2015 at 1:54 PM, Simon Génier wrote:\r\nHi,\r\n\r\nSince exceptions are listed on a per method method basis, I think the most straightforward way to support that would be to generate an enum such as\r\n\r\nenum MyMethodCallResponse {\r\nOk(ReturnValue),\r\nErr1(ExceptionType1),\r\nErr2(ExceptionType2),\r\nThriftErr(ThriftErr),\r\n}\r\n\r\nfor each service method. I looked at the Haskell implementation for ideas, but even they map Thrift exceptions to the exceptions available in the language, so we on our own here. The tricky part will be to generate good names for the enum members so it is not a pain to use.\r\n"}}