Improved exceptions and reporting exceptions for command-line compiler.

You just defined you helping function createTypeError(...), why not using it here?