Add error handling for recursive blocks