Changed macro CHECK_ERROR to throw a std::runtime_error exception and print information about where the error happened.