Skip to content
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

Rework errors to be plain structs #136

Merged
merged 1 commit into from Nov 22, 2016
Merged

Rework errors to be plain structs #136

merged 1 commit into from Nov 22, 2016

Conversation

DavidAntaramian
Copy link
Contributor

@joshsmith This is what I discussed with you and @tlvenn over in #132. This reforms the exceptions that were being created into plain structs. They still carry largely the same information. I have retained the MissingAPIKeyError as an actual error.

Also, to avoid confusion, I have refrained from naming the plain structs ending in Error, as that is typically reserved for actual exceptions per the naming documentation.

I suggest that we use this to close #132. Soon we can also implement dialyzer which will catch more of this upfront as @tlvenn mentioned.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 14.286% when pulling 7f6b000 on improvements/132 into b749232 on 2.0.

@joshsmith joshsmith merged commit ebcae3f into 2.0 Nov 22, 2016
@joshsmith joshsmith deleted the improvements/132 branch November 22, 2016 21:08
@@ -294,30 +323,21 @@ defmodule Stripe do
|> handle_response()
end

@spec handle_response(http_success | http_failure) :: {:ok, map} | {:error, Exception.t}
@spec handle_response(http_success | http_failure) :: {:ok, map} | {:error, struct}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the typespec use api_error_struct instead of struct ?

@@ -275,7 +304,7 @@ defmodule Stripe do
@doc """
A low level utility function to make an OAuth request to the Stripe API
"""
@spec oauth_request(method, String.t, map) :: {:ok, map} | {:error, Exception.t}
@spec oauth_request(method, String.t, map) :: {:ok, map} | {:error, struct}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the typespec use api_error_struct instead of struct ?

@tlvenn
Copy link
Contributor

tlvenn commented Nov 27, 2016

Not sure how github behave when you annotate some code once the PR has been merged. In any case, there are 2 instances where I believe the typespec could be more strict to target api_error_struct instead of struct in lib/stripe.ex

@DavidAntaramian
Copy link
Contributor Author

@tlvenn Thanks for pointing those out. Missed them in my rework. Opening an issue for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants