Skip to content
Snippets Groups Projects
Commit 2655f77c authored by Jean-Paul Calderone's avatar Jean-Paul Calderone
Browse files

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
1 merge request!111Generate a correct response for the voucher-already-paid case
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment