code-corps / code-corps-api

Elixir/Phoenix API for Code Corps.
https://www.codecorps.org
MIT License
234 stars 86 forks source link

Look through StripeService modules and remove error swallowing #611

Open begedin opened 7 years ago

begedin commented 7 years ago

Problem

A lot of our StripeXService modules use with statements in their public functions.

Some of those with statements have else blocks with a catch all clause along the lines of

with
  #...
do
  # ...
else
  # ...
  _ -> {:error, :unhandled}
end

The problem with that is that this behavior basically swallows an error, still causes a function clause mismatch error in the controller that called the function (since the controller is not expecting an {:error, :unhandled} reply, but ends up swallowing any useful information which sentry might log otherwise, such as what the actual response was, where it happened, etc.

We should go through all of our with blocks, remove these catch-all clauses and if that means the else block is empty, remove the else block altogether. As unexpected things occur, sentry will log these things and then we can progressively add handling for specific types of errors.

We actually do this with some transaction statements to, so we should remove it from there as well.

Subtasks

References

https://github.com/code-corps/code-corps-api/issues/543#issuecomment-265758601 for some additional information.

begedin commented 7 years ago

@JoshSmith I put this in the "Improve donations" milestone, since the changes here don't really block us from launching, but I'm fine with you moving it to "launch donations" if you feel we need it.