-
Notifications
You must be signed in to change notification settings - Fork 349
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
Conversation
@@ -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} |
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.
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} |
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.
Should the typespec use api_error_struct instead of struct ?
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 |
@tlvenn Thanks for pointing those out. Missed them in my rework. Opening an issue for that |
@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.