pet_array_embed: improve error handling