There is an excellent online learning path on this topic: https://academy.mendix.com/link/path/81/Error-Handling
I can recommend doing it.
On topic: latestError is available inside the error handling branch inside a microflow.