Handle C++ exception within C-API

There was one c++ exception that could be thrown inside `compile_block`. We did not correctly catch this, which lead to a crash as described in #789! This PR should fix this and the correct error message should be propagated. I also added re-throw clauses for all other catch clauses, since we do not want to silently ignore possible problems!