I’m not sure whether you have over thought this, or I have under thought it, but it seems to me that if it is just two items to run, you can just set parameter “error”, there is no need to test the value, you just exit {parameter “error”} at the end.
If there are multiple points where you want to save an exit code, things become a whole lot more complex.
I met with similar requirement from our teams, what I suggested, " Edit - include custom success criteria with relevance “the following relevance clause evaluates to false” which will always be False" for example if you are running windows task & if you put not windows of operating system as custom success criteria in that case you will have your custom exit code with completed status not failure.