I am having a few troubles with Error reporting on scheduled server actions.
Scenario, I have a Library action that calls 3 different APIs from various providers as well as reads and writes to and from various database tables.
If any error happens I would like the script to stop processing and to write an entry into a database table with the error it encountered.
I have tried with Pass Errors enabled on the API actions, and that stops the script on error, but does not write anything to my database table showing the error because the script stopped so it never got to the next action.
I have put the API action in a try/catch step, and added the database insert into the catch area, and that also does not work while Pass Errors in enabled.
I have turned off Pass Errors while still inside a try/catch step, but then it never stops the script, and also never runs what is inside the Catch step.
This all stems from this thread API Action Throw Error Option
The only solution I have found is to not use try/catch, add my API action, turn off Pass Errors, and to add a condition step after, checking for requestStatus from the API return, and if true writing the error to my database, and then adding a server response 500 step to stop the rest of the server action from running. This works, however adds a lot of steps to my script if I need to add a condition and a database insert/update and a server response for every API interaction i have inside the script.
This also does not account for any and all errors that could possibly happen, such as a database insert/update error.
Is there any way to do this differently, where regardless of which step fails, whether an API failure or a database error the error can be inserted into my database once the server action stops, or have I just confused myself somewhere along the line.