handle the IOException thrown by `payForVoucher`
`throwError voucherAlreadyPaid` above is a red herring. That codepath works fine. It's just unreachable because `payForVoucher` never returns `Left AlreadyPaid`. Instead, it does `throwIO AlreadyPaid`. Servant doesn't know how to do anything good with `AlreadyPaid` (a `PaymentError` rather than a `ServerError`) so it logs it and returns a 500 error to the client. This change adds an exception handler to the `payForVoucher` call that transforms all `PaymentError` exceptions into `Left e` values which `charge` is already handling. `throwError` will eventually throw a `ServerError` with correct details filled in for these.
parent
3b53cfc1
No related branches found
No related tags found
Loading
Please register or sign in to comment