Added error checking in all app/cpp-py files