Correctly check for compilation errors and throw them. Fixes #2