I'm making a signup process that ends with a final script where the majority of the heavy lifting is done, after a user has made payment. These processes include:
- Updating our sales DB several times
- Making an external API post
- Downloading, amending and uploading a file via SFTP
- Sending confirmation emails
Essentially there's a lot of things to potenatially fail individually, all of which are critical and rely on the previous one working. I don't just want the final method to do all this to be along the lines of
try {
$Signup->doEverything();
}
catch( Exception $e ) {
echo "Something went wrong"
}
because that is no use to anybody.
I've ended up with a massive nested list of all these final processes that is now 11 deep - it does work, if one of the processes fails it dies with the correct exception, but seeing this many nests I just assume there should be a better way of handling all these processes.. Is this bad practice? Are there better solutions for dealing with large amounts of critical processes like this?