Automation help with an exception situation

Hey mate, welcome to the community. Can you please format your code as per here.

Cheers.