How to read/access error message on github action

Hi ,
I can’t find a way in github action to read the error message of a failing step.

Error: Validation Failed: {“resource”:“PullRequest”,“field”:“head”,“code”:“invalid”}

Step2 executed only on failure of the previous test
I would like to create a condition based on the error message returned by the previous step1.
Is there a way to analyze the logs inside a step

Thanks in advance for your help