exception handler for module.main invocation

on exception caught, set module state to ERROR and rethrow the exception