Cheeries eaten with worms
Your cherries are probably infested with the maggot of the western cherry fruit fly. I cannot tell you if it is dangerous to eat the infested fruit, but I personally would not. Check with your health care provider if you are concerned about the fruit you've already eaten.
The best course is to spray your cherry tree to prevent the western cherry fruit fly from depositing its eggs under the skin of the cherry fruit.
The following publication lists cultural and chemical controls for the fruit fly. https://pnwhandbooks.org/insect/tree-fruit/cherry/cherry-western-cherry-fruit-fly
Use the section on "chemical control--Home use" as these are available at your grange and other farm supply stores. Many of the products are organic.
As always when applying chemicals read the label carefully and follow all instructions.
Thanks for using Ask an Expert.