pet_scop_from_pet_stmt: fix error handling