Moved error check to general cuda utils