Refactoring result error handling from transpile

The result is only used when the transpile process does not throw an
exception. This takes into account the result possibly being undefined
and then accessed as an object, resulting in an additional exception.
Merge pull request #3 from ethul/topic/errors

Refactoring result error handling from transpile