-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add exceptions #20
base: master
Are you sure you want to change the base?
Add exceptions #20
Conversation
Maybe this should require Thrift 0.10 in mix.exs (via The |
Good job! I had found the generated struct_names() not include exception names, so I add a PR(apache/thrift#975) to thrift compiler to generate exception_names() meta info. |
Sorry for not getting back sooner. |
Ah, sorry for not getting back. |
@tbug apparently, so is apache ;) To say we're disappointed with the speed of thrift releases is an understatement. |
@scohen Ha, alright. I guess I'm happy it's not just me then 😄 I'm not really following thrift dev, so I have no idea how far we are from 0.10, |
@tbug As far as I can tell from the outside, they've tagged the release and are now doing... something. This PR relies on deeper metadata around functions and exceptions, which were added to 0.10. |
@@ -209,6 +248,8 @@ defmodule Riffed.Client do | |||
call_thrift(new_client, call_name, args, retry_count + 1) | |||
err = {:error, _} -> | |||
{new_client, err} | |||
exception = {:exception, exception_record} -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've found that this isn't enough to catch the exception.. The actual erlang thrift client will throw
the exception, not just return it. So when working with services that go through the thrift client (maybe the tests here don't?), the GenServer
will EXIT
before we reach this case
statement
[Exception] ->
throw({NewClient, {exception, Exception}})
I had to modify the :thrift_client.call
to look something like this:
{thrift_client, response} = try do
:thrift_client.call(client.client, call_name, args)
catch
exception_response = {thrift_client, {:exception, exception}} -> exception_response
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@binaryseed is this the behavior in 0.9.3 or in head? They made a bunch of changes in head (and in the forever-upcoming 0.10 release)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe so, the code I reference is in master
and I'm running based of a fork of elixir-thrift
that points at master, not 0.9.3
Thrift now raises exceptions, which is now handled correctly and tested.
@binaryseed Sorry it's been so long, but I updated exception handling on the v1_5_0 branch. Please give it a shot. |
This PR adds exceptions to the client, server and struct modules. It's dependent on thrift 0.10 though, and targets the 1.5 branch.