I am creating a wrapper API over a payment API that is pretty hard to use. All sort of things can go wrong when you do payment transactions; there is a problem with the card, the payment was refused by the clients bank, 3D secure issue and the list goes on (around 20 error codes). From the payment API this information is provided in a normal String
field. The error code will e.g. be Card_not_eligible
.
What I want to do is to provide a better way to handle such errors. I have been thinking of creating own exceptions for each of these error codes. Does this sound crazy? If not would you use checked or unchecked exceptions? Forced catch of 20 errors or more is probably not an good idea?
Or do you have a better solution for this type of error handling?