code-corps / code-corps/code-corps-api
Look through StripeService modules and remove error swallowing
- 主要语言
- 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.
贡献指南
调研方向
首先定位所有 StripeService 基础模块及其公共函数,然后检查 issue 中指出的 with 块和 transaction 语句。查看相关测试和引用的 issue 以了解上下文。完成的标志是移除兜底错误子句和空的 else 块,并且测试不再期望 {:error, :unhandled} 响应。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- elixir
- 领域
- api, backend, payments
- Issue 类型
- 重构
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100