These error exception are already stated, do not overwrite it with not very meanful new general error message.
Bugs corrected. Comaring module names was restricted to length of the __main__ module. I.e. first len(__main__) chars were compared.