code-corps / code-corps/code-corps-api

Look through StripeService modules and remove error swallowing

オープン
#611 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Elixir
スター
234
フォーク
82
PR マージ指標
30日以内にマージされた PR はありません

説明

# 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

```Elixir
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

* [ ] Go through all `StripeService` base modules
* [ ] Remove catch all clauses from if blocks
* [ ] Fix tests that might brake (basically remove tests that expect an `{:error, :unhandled}` reply.
* [ ] Do the same for transaction statements

# References

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

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。