Sorry, but I didn't understand. Which error? Wouldn't it be better to work on the root cause of the problem instead of disabling and enabling the port?
I think it will be something a bit complex to do, perhaps with APIs but you would need to integrate it with a monitoring system.
I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.
Please, if this post was useful, leave your kudos and mark it as solved.