Two ways to check if the error page has run.
1) Use sessionStorage. This method works completely on the client side.
Add the following code to the error template
<
<script type="text/javascript">
if(apex.item('pFlowStepId').getValue() == 36){
sessionStorage.setItem('ErrorFlag','#MESSAGE#');
}
</script>
This will set the message to a sessionStorage item.
Add a dynamic action that runs on page load.
The type of action is use javascript.
var v_message;
v_message = sessionStorage.getItem('ErrorFlag');
sessionStorage.removeItem('ErrorFlag');
$s('P36_MESSAGE',v_message);
This get the message form sessionStorage. Remove the item. And display the text.
2) Use a page item. This method uses the server.
In the code that does the validation set a page item. For example
apex_util.set_session_state('P36_ERROR_FLAG',1);
return 'An error has occured and the flag is set '||:P36_ERROR_FLAG;
Use a dynamic action to get the value of the page item form the server. Simple use a "Set value" action of type pl/sql function.
Test it by clicking the submit button.