Hey gus, how are you? Could you help me with this ...
# codereview
j
Hey gus, how are you? Could you help me with this piece of code?
Copy code
if (ex !is PayInProcessException || ex.errorCode == PayInServiceErrorCode.PAYMENT_PROCESS_UNAVAILABLE_ERROR || ex.errorCode == PayInServiceErrorCode.WALLET_SERVICE_ACCOUNT_NOT_FOUND) {
                sendWorkerFailedMessage(ex, purchaseDto, walletDto, merchantDto, headerParam)
            }
j
ex !is PayInProcessException
seems strange to me. It seems the catch block should have dealt with the type in the first place. If a bunch of exceptions that are not
PayInProcessException
share common processing, maybe they should have a common parent type you could check for? Maybe not, but more context would help decide here.
Regarding the error code checks, probably the set of error codes could be defined as an actual
Set
named based on the reason why they are treated the same, and checked with
ex.errorCode in yourSet