Use a Custom action and a Validate action.
Add the Validate action at the end of the step. Make sure the match text string in the Validate action does not exist in the source of the object. In the example below, the match text is the error message for a 500 error: '500 Error Found During Testing'.
If the object's return code is 500, the match text in the Validate action will be found and the the script will fail with a Content Match error.